因此,当我尝试向我的 discord python bot 添加状态时,它不会显示在 discord 上,运行代码时不会显示任何错误,只是状态不会自行显示。< /p>
#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'))
如果有人知道如何解决这个问题,请帮忙。
答案 0 :(得分:0)
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
我在我的测试机器人中尝试了你的代码,它运行良好。我附上了下面的屏幕截图和上面的代码。不知道为什么它不适合你。 [这是我的全部代码,中间或末尾没有附加任何内容]。
注意:导入配置有我的令牌(所以它不是必需的导入)