【发布时间】:2021-11-24 13:45:24
【问题描述】:
我想在给我的 discord bot 发出命令=hi 后阅读作者发送的消息。所以我用我在网上找到的这段代码来获取作者发送的内容:
msg = await client.wait_for('message', check=check) #error goes here, 'check' is not defined
await ctx.send(msg.content)
但问题是check在这个函数运行时没有定义
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'check' is not defined
我该如何解决?
这个函数前面我没有定义check,但是check怎么定义呢?
【问题讨论】:
-
你在这行之前定义了检查吗?
-
您好,可以出示您的代码吗?
-
@MoeedAzhar 不,但是如何?
-
这个函数前面没有定义check,怎么定义check?
标签: python discord discord.py undefined