discord.py:如果不是成员则不计算

时间:2020-07-11 13:21:33

标签: discord.py

每次我运行不引用成员的命令时,它都不会计算if not member,而且我也不知道为什么...

代码:

@client.command()
@commands.has_permissions(ban_members=True)
async def mute(ctx, member: discord.Member,arg='Motivo non specificato'):
    if not member:
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name="Per favore specifica l'utente!",
            icon_url="'https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'"
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    role = get(member.guild.roles, id=int("691009285634654229"))
    if (ctx.author == member):
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name=f'Non puoi mutare te stesso!',
            icon_url='https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    if get(member.roles, name='Mutato'):
        embed = discord.Embed(
           color=discord.Colour.red()
        )
        embed.set_author(
            name=f'{member.display_name} è attualmente mutato',
            icon_url=f'{member.avatar_url}'
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    if get(member.roles, name='Triumvirato'):
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name=f'Non puoi mutare un triumviro!',
            icon_url='https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    if get(member.roles, name='Co-Triumvirato'):
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name=f'Non puoi mutare un co triumviro!',
            icon_url='https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    if get(member.roles, name='Presidente ad Interim del LMII'):
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name=f'Non puoi mutare il presidente!',
            icon_url='https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    if get(member.roles, name='Moderatori'):
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name=f'Non puoi mutare un moderatore!',
            icon_url='https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return
    embed = discord.Embed(
        color=discord.Colour.green()
    )
    embed.set_author(
        name=f'{member.display_name} è stato mutato',
        icon_url=f'{member.avatar_url}'
    )
    embed.set_footer(text=f'Motivo: {arg}')
    await member.add_roles(role)
    await ctx.send(embed=embed, delete_after=10.0)
    embed = discord.Embed(
        color=discord.Colour.gold()
    )
    embed.set_author(
         name=f'{ctx.author._user} ha mutato {member._user}',
         icon_url=f'{member.avatar_url}'
    )
    embed.set_footer(text=f'Motivo: {arg}')
    embed.add_field(
        name='Utente mutato:',
        value=f'{member._user}',
    inline=True
    )
    embed.add_field(
        name='Mutato da:',
        value=f'{ctx.author._user}',
        inline=True
    )
    embed.add_field(
        name='Durata:',
        value='∞',
        inline=True
    )
    channel = client.get_channel(729553772547932190)
    await channel.send(embed=embed)
@mute.error
async def mute_error(ctx, error):
    if isinstance(error, commands.CheckFailure):
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name="Non ti è permesso mutare",
            icon_url='https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'
        )
        await ctx.send(embed=embed, delete_after=10.0)

1 个答案:

答案 0 :(得分:0)

if not member:
        embed = discord.Embed(
            color=discord.Colour.red()
        )
        embed.set_author(
            name="Per favore specifica l'utente!",
            icon_url="'https://cdn.discordapp.com/attachments/640563710104043530/730639329453670420/DuscePeppe_FRIULI.png'"
        )
        await ctx.send(embed=embed, delete_after=10.0)
        return

问题是语法错误,这是没有使命令执行的多余字符。