python - Discord.py 使用 wait_for 检查用户输入
问题描述
我正在尝试创建一个日志设置命令,例如:“消息编辑日志会打开吗?” 如果是:发送频道 ID。我试图创建的命令与此类似。我的代码是这样的。我是 discord.py 的菜鸟。这是代码,感谢您的帮助。
注意:执行命令时我没有得到任何输出。
@bot.command(name="logsetup")
@commands.guild_only()
@commands.has_any_role("Head Admininstaror", "Adminstaror", "Owner")
async def log_setup(self, ctx):
await ctx.send("Message edit logs: On/Off")
msg = await bot.wait_for('message', check=lambda message: message.author == ctx.author)
if msg.content.lower() == "on":
print("Working.")
await ctx.send("Send the channel ID.")
msg = await bot.wait_for('message', check=lambda message: message.author == ctx.author)
editedMessageChannel = msg.content
ctx.send("Channel is set.")
解决方案
我在@Kelo 的帮助下发现了问题。感谢他/她,我发现我忘了添加自我。
推荐阅读
- reactjs - 重新排序具有状态的组件时出现问题
- react-native - React Native - 模块 AppRegistry 不是注册的可调用模块
- javascript - 这段有趣的 JavaScript 代码是如何工作的?
- apache - 如何使用空查询参数进行 htaccess 重定向?
- google-cloud-platform - 为什么 Google Cloud Spanner 中节点越多更新延迟越高
- javascript - 反应从另一个文件夹导入 svg 文件
- python - Spotify Python API 调用超时问题
- c++ - 打印用户选择的行
- javascript - React JS:为什么我在 componentdidMount() 处出现错误?
- angular - Angular:如何将服务中的数据绑定到组件,以便服务中的新数据更新组件?