Check if message reply is a reply type message discord.py

Viewed 3836

I have the following basic python discord bot code:

@bot.command()
async def replyTest(ctx):
    await ctx.send('Reply to this message')
    def check(m):
        return m
    msg = await bot.wait_for("message", check=check)
    print(msg)

Is there a way to return m only when m is a reply type message?

1 Answers

You can simply check if the message has a reference.

def check(m):
    if m.reference is not None and not m.is_system :
         return True
    return False

Additionally if you want to check if the reference points to a message

def check(m):
   if m.reference is not None:
        if m.reference.message_id = some_msg.id
            return True
   return False

References:

Related