Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Discord bot AttributeError:“str”对象没有属性“id”_Python_Discord.py - Fatal编程技术网

Python Discord bot AttributeError:“str”对象没有属性“id”

Python Discord bot AttributeError:“str”对象没有属性“id”,python,discord.py,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 ==

我在搞一个机器人,但我不知道怎么禁止某人

    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.")

不要将on_消息事件用于ban命令 改用命令处理程序

@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

欢迎来到堆栈溢出!寻求调试帮助的问题此代码为什么不起作用?必须包括所需的行为、特定的问题或错误以及在问题本身中重现这些问题所需的最短代码。没有明确问题陈述的问题对其他读者没有用处。请参阅:。此错误表示角色或作者是字符串。试着打印出这些值。虽然不是每个人都使用ext.commands,但值得指出的是,他的问题是由于在用户名上使用Client.kick而不是用户对象本身造成的。。。