【发布时间】:2019-06-13 05:53:28
【问题描述】:
我正在使用 cogs 来缩短和组织我的 Discord 机器人。然而,在尝试“事件”齿轮时,我面临一个 NameError of changePlaying not being defined 尽管它实际上是关于 on_ready 命令
A:我忘记导入 discord.ext,因此导入了它。 B:我尝试在 changePlaying 事件内外更改可能状态列表的位置
PlayingList = [Maximus.py.","!help"]
async def changePlaying(self):
while True:
await self.bot.change_presence(game=Game(name=random.choice(PlayingList)))
await asyncio.sleep(120)
async def on_ready(self):
print('Logged in as')
print(self.bot.user.name)
print(self.bot.user.id)
print('-----------------------------------------')
print('Log in complete')
for x in range(5):
print("")
self.bot.loop.create_task(changePlaying(self))
嗯,我认为很明显预期的结果是什么,但要澄清机器人应该启动。它确实上线并且确实听命令但状态栏没有改变
【问题讨论】:
标签: python-3.6 discord.py