我的 discord bot 命令不起作用,但它在 cmd

时间:2021-03-29 22:18:05

标签: discord

这是我的命令,它似乎不起作用,但是当我只在 cmd 中执行 tfollow {channel} 时,它起作用了,有什么想法吗?我尝试做我知道怎么做的所有事情,但它似乎对我不起作用,尽管通过机器人对我的朋友有效

@bot.command() @commands.cooldown(1, 600, type=commands.BucketType.user)

async def tfollow(ctx, channel, amount: int=None):

print(f'{ctx.author} | {ctx.author.id} -> /tfollow {channel}')
if ctx.channel.type != discord.ChannelType.private:
    if ctx.channel.id == bots_channel or ctx.author.id in administrators:
        if str(channel.lower()) in tfollow_cooldown and ctx.author.id not in administrators:
            try:
                await ctx.message.delete()
            except:
                pass
        else:
            try:
                if '-' in str(channel):
                    raise Exception
                max_amount = 0
                if ctx.author.id in administrators:
                    tfollow.reset_cooldown(ctx)
                    max_amount += 1000
                premium = discord.utils.get(ctx.guild.roles, name='Premium')
                if premium in ctx.author.roles:
                    max_amount += 1000
                diamond = discord.utils.get(ctx.guild.roles, name='Diamond')
                if diamond in ctx.author.roles:
                    max_amount += 750
                gold = discord.utils.get(ctx.guild.roles, name='Gold')
                if gold in ctx.author.roles:
                    max_amount += 450
                silver = discord.utils.get(ctx.guild.roles, name='Silver')
                if silver in ctx.author.roles:
                    max_amount += 250
                bronze = discord.utils.get(ctx.guild.roles, name='Bronze')
                if bronze in ctx.author.roles:
                    max_amount += 100
                booster = discord.utils.get(ctx.guild.roles, name='Booster')
                if booster in ctx.author.roles:
                    max_amount += 75
                _75 = discord.utils.get(ctx.guild.roles, name='+75')
                if _75 in ctx.author.roles:
                    max_amount += 75
                _25 = discord.utils.get(ctx.guild.roles, name='+25')
                if _25 in ctx.author.roles:
                    max_amount += 25
                _10 = discord.utils.get(ctx.guild.roles, name='+10')
                if _10 in ctx.author.roles:
                    max_amount += 10
                _5 = discord.utils.get(ctx.guild.roles, name='+5')
                if _5 in ctx.author.roles:
                    max_amount += 5
                max_amount += 25
                if amount is None:
                    amount = max_amount
                elif amount > max_amount:
                    amount = max_amount
                if amount <= max_amount:
                    premium = discord.utils.get(ctx.guild.roles, name='Premium')
                    if premium in ctx.author.roles:
                        position = len(queue) + 1
                        # embed = discord.Embed(color=16379747, description=f'Added `tfollow-{channel}-{amount}` to queue! (`1/{position}`)')
                        embed = discord.Embed(color=16379747, description=f'Adding `{amount}` followers to `{channel}`! (`1/{position}`)')
                        await ctx.send(embed=embed)
                        queue.insert(0, f'tfollow-{channel}-{amount}')
                    else:
                        position = len(queue) + 1
                        # embed = discord.Embed(color=16379747, description=f'Added `tfollow-{channel}-{amount}` to queue! (`{position}/{position}`)')
                        embed = discord.Embed(color=16379747, description=f'Adding `{amount}` followers to `{channel}`! (`{position}/{position}`)')
                        await ctx.send(embed=embed)
                        queue.append(f'tfollow-{channel}-{amount}')
                    if ctx.author.id not in administrators:
                        tfollow_cooldown.append(str(channel.lower()))
                        await asyncio.sleep(600)
                        tfollow_cooldown.remove(str(channel.lower()))
            except:
                embed = discord.Embed(color=16379747, description='An error has occured while attempting to run this command!')
                await ctx.send(embed=embed)
                tfollow.reset_cooldown(ctx)
    else:
        await ctx.message.delete()
        tfollow.reset_cooldown(ctx)

0 个答案:

没有答案