【发布时间】:2021-07-29 11:13:03
【问题描述】:
我是 python 的新手,所以如果问题很愚蠢,我希望你们能帮助我。 机器人不是每 5 秒更新一次状态(我花了更多的时间,比如 5 分钟,但它也没有用)。它显示服务器的数量,并且不会更改为第二状态。
from discord.ext import commands, tasks
from itertools import cycle
@tasks.loop( seconds = 12 )
async def changeStatus():
status = cycle( [f' on { len(client.guilds) } servers', '~help'] )
await client.change_presence( activity = discord.Activity( type = discord.ActivityType.playing, name = next(status) ) )
@client.event
async def on_ready():
print( 'bot connected' )
changeStatus.start()
【问题讨论】:
-
如果你无法解决这个方法,我使用 random.choice(list),它可以正常工作
标签: python discord discord.py bots