我想为我的 discord 机器人设置自定义状态(又名 "Playing | $help for commands")

I want to set a custom status for my discord bot (aka "Playing | $help for commands")

我正在使用 discord.py 重写并使用 AutoShardedBot class 系统来制作我的机器人。我想设置自定义播放状态,但每次搜索它时,答案都是 discord.Client()。这可能吗?

以下是在机器人启动时设置自定义播放状态的示例:

@bot.event
async def on_ready():
    print("Ready!")
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name="| $help for commands"))

这不是 唯一的 方法,但这是我使用的一种方法,因为它允许您轻松地在 listening、[=13] 之间切换=],等等


如果您想将 on_ready() 事件添加到齿轮:

def MyCog(commands.Cog):

    def __init__(bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready():
        print("Ready!")
        await bot.change_presence(...)

参考文献:

//set your status
client.user.setActivity("Being a bot or something lol", {type: "Playing",})