【发布时间】:2022-01-25 19:08:44
【问题描述】:
我想要一些代码,使用 当前代码: 错误:未定义统计数据 我需要使用 task.loop() 每 30 分钟将状态从 Playing Stat = True
@tasks.loop(minutes=30)
async def change_status():
new_status = "<help" if Stat else f"{len(client.guilds)} servers"
await client.change_presence(status=discord.Status.online, activity=discord.Game(new_status))
Stat = not Stat
client.guild 而不是 bot.guild 的代码
【问题讨论】:
-
我想你必须在 Stat 变量上使用 global 关键字,而且,你是否将你的 Bot 定义为客户端或机器人? (我的意思是,你的 Bot 对象的变量名是什么?)
-
我把它定义为客户端
-
你是否将 Stat 变量设置为函数内部的全局变量?
标签: python discord.py