简体   繁体   English

Discord.py 机器人状态未显示

[英]Discord.py bot status not showing

So, when i was trying to add a status to my discord python bot, it wouldn't show up on discord, when running the code no errors would show up, it's just that the status wouldn't show itself.所以,当我试图向我的 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'))

If anyone knows a fix to this please help.如果有人知道解决此问题的方法,请提供帮助。

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

I tried your code in my test bot and it was working totally fine.我在我的测试机器人中尝试了你的代码,它工作得很好。 I have attached the screenshots below and the code above.我附上了下面的截图和上面的代码。 Not sure why it wouldn't work for you.不知道为什么它不适合你。 [This is my entire code and has nothing extra attached in between or at the end]. [这是我的全部代码,中间或末尾没有任何附加内容]。

Note: import config has my token (so it isn't a necessary import)注意:导入配置有我的令牌(所以它不是必要的导入)

在此处输入图像描述

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM