首页 > 解决方案 > 使用 python 断开用户(不和谐机器人)

问题描述

我试图发出一个断开用户连接的命令,但不明白为什么它会给我这个错误:'Client' object has no attribute 'command'(这只是机器人代码的一部分)

@client.command
async def leave(ctx, member : discord.Member):
    await discord.Member.disconnect()



 if msg.startswith("$kick."):
        users = message.guild.members
        count = 6
        name = ""
        while count < len(message.content):
            name = name + str(message.content[count])
            count = count + 1
        #till here we just got the name
        x = 0
        while x > id.member_count:
            if name == users[x]:
                leave('was kicked',user[x])
                break

标签: pythoncommandclientdiscord.pydisconnect

解决方案


你忘了()后面@client.command。将其更改为@client.command()


推荐阅读