【发布时间】:2021-11-29 17:30:19
【问题描述】:
Python 刚开始在 discord.py 中使用 cogs,所以我将我的代码复制到 cogs 中,但是之前有效的一件事在 cog 中不起作用,我不知道为什么。下面的代码示例。
sverify_index=0
sverify_msg_id=""
@commands.Cog.listener()
async def on_message(self, message):
if message.channel.id == 888529033405530183 and message.author.id != 887542628063780864:
global sverify_index, sverify_msg_id
sverify_index += 1
sverify_list = []
sverify_list.append(sverify_index)
目前我得到的错误是
line 19, in on_message
sverify_index += 1
NameError: name 'sverify_index' is not defined
请帮忙。
【问题讨论】:
标签: python python-3.x discord discord.py