【问题标题】:Discord.py rewrite returning wrong messageDiscord.py 重写返回错误信息
【发布时间】:2023-04-03 21:21:01
【问题描述】:

我想让我的不和谐机器人做一个小表格。但是,当我输入“N”表示“否”时,我会得到如果输入“Y”(表示“是”)会得到的答案。有人可以帮忙吗?

@client.command()
async def shad(ctx):
    await ctx.send("Do you like Pugs(Reply with Y/N)")


    def check(m):
        return m.content in ["Y", "N"] and m.channel == ctx.channel

    await client.wait_for("message", check=check)
    await ctx.send("Shad does love you")
    if "N" in ctx.content:
        await ctx.send("Shad does not love you")

【问题讨论】:

  • 您总是发送"Shad does love you" 消息。它可能应该放在if 之后的else 块中。

标签: python-3.x discord.py-rewrite


【解决方案1】:

你可以这样做

@client.command()
async def shad(ctx):
    await ctx.send("Do you like Pugs?[Y/N]")

    awnser = client.wait_for('message', check=lambda message: message.author == ctx.author)
    if awnser in ['Y', 'y', 'yes', 'Yes']:
        #Do something
    else:
        #do something

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-21
    • 1970-01-01
    相关资源
    最近更新 更多