【问题标题】:Discord.py checking user input with wait_for [closed]Discord.py 使用 wait_for 检查用户输入 [关闭]
【发布时间】:2020-10-10 17:55:35
【问题描述】:

我正在尝试创建一个日志设置命令,例如:“消息编辑日志会打开吗?”如果是:发送频道 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.")

【问题讨论】:

  • 您在结尾处缺少await ctx.send
  • 是的,你是对的,但即使发送通道 id 也没有执行,也没有错误。
  • 我刚刚在我的机器人上运行了它。将 await 添加到 ctx.send("Channel is set.") 时效果很好。哦,因为它看起来像是在齿轮中,所以请确保在 bot 位之前添加 self.。例如msg = await self.bot.wait_for(' etc...
  • 你可以像commands.command(name='fun', aliases=['a', 'b'])这样传递命令名和别名

标签: python discord discord.py


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-06
    • 2021-02-16
    • 2011-10-24
    • 2014-02-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-05
    相关资源
    最近更新 更多