“未公开的客户会话”

时间:2019-01-27 14:18:12

标签: python bots discord discord.py

我正在尝试为我的不和谐服务器创建一个机器人,该机器人将在发出特定命令时发出角色。 (这是一个动漫服务器,只有在拥有排名的情况下,每个节目的聊天窗口才可用)

我正在浏览该网站,我只是复制并粘贴了代码,然后像空白菜鸟一样填了空白。这是代码:

    import discord
    from discord.utils import get

    client = discord.Client()

    @client.event
    async def on_message(message):
        if message.author == client.user:
            return
        if message.content == '!SAO':
            role = get(message.server.roles, name='SAO Fan')
            await client.add_roles(message.author, role)
        if message.content == '!AOT':
            role = get(message.server.roles, name='AOT Fan')
            await client.add_roles(message.author, role)
        if message.content == '!7DS':
            role = get(message.server.roles, name='7DS Fan')
            await client.add_roles(message.author, role)
        if message.content == '!naruto':
            role = get(message.server.roles, name='Naruto Fan')
            await client.add_roles(message.author, role)
        if message.content == '!BNHA':
            role = get(message.server.roles, name='BNHA Fan')
            await client.add_roles(message.author, role)
        if message.content == '!FairyTail':
            role = get(message.server.roles, name='Fairy Tail Fan')
            await client.add_roles(message.author, role)
    client.run=('token')

当我运行.py文件时,它不起作用,当我将其放入命令提示符时,它说 “未公开的客户会话” “ client.session:”

1 个答案:

答案 0 :(得分:-1)

此问题记录在这里:

https://github.com/Rapptz/discord.py/issues/398

client.run(token)中没有=

也许您还需要运行client.close()