Discord bot AttributeError:' str'对象没有属性' id'

时间:2018-05-22 01:28:09

标签: python discord.py

我正在制作机器人,但我无法弄清楚如何禁止某人...

    if message.content.upper().startswith('CHILL BAN'):
        if "447929519945416734" in [role.id for role in 
message.author.roles] or "448191759739256842" in [role.id for role in 
message.author.roles] or message.author.id == "218156043799101452":

            await bot.kick(message.mentions[0].name)
            await bot.send_message(message.channel, "Someone has been 
banned!")
            #["<@356065937318871041>"]

        else:
            await bot.send_message(message.channel, "You do not have 
sufficient privileges.")

1 个答案:

答案 0 :(得分:0)

不要将on_message事件用于禁止命令 改为使用命令处理程序

@bot.command(pass_context=True)
async def ban(ctx, user: discord.Member):
    await bot.ban(user)
    await bot.say(f"{user.name} Just got banned")
# Do extra stuff here if you want