首页 > 解决方案 > 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.")

标签: pythondiscorddiscord.py

解决方案


我在@Kelo 的帮助下发现了问题。感谢他/她,我发现我忘了添加自我。


推荐阅读