首页 > 解决方案 > Discord.py 机器人状态未显示

问题描述

因此,当我尝试向我的 discord python 机器人添加状态时,它不会显示在 discord 上,运行代码时不会出现错误,只是状态不会显示自己。

#Connection to discord
@client.event
async def on_ready():
    print({client.user}, 'has connected to Discord!')
    await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='~help'))

如果有人知道解决此问题的方法,请提供帮助。

标签: pythondiscord

解决方案


import discord
import os
import config
import sys



client = discord.Client()



@client.event
async def on_ready():
        print({client.user}, 'has connected to Discord!')
        await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='~help'))

client.run(config.token)                        #imports token from the config.py

我在我的测试机器人中尝试了你的代码,它工作得很好。我附上了下面的截图和上面的代码。不知道为什么它不适合你。[这是我的全部代码,中间或末尾没有任何附加内容]。

注意:导入配置有我的令牌(所以它不是必要的导入)

在此处输入图像描述

在此处输入图像描述


推荐阅读