Search code examples
pythondiscord.pymention

How can I make my discord.py bot mentions someone mentioned in my message?


So I know that there is a similar question on stack overflow but it is for discord.js and I use discord.py so can someone tell me (also this is my first question on stack overflow)


Solution

  • Okay so the above one is almost correct. The solution is:

    @client.command()
    async def something(ctx, target:discord.Member = None):
        if target == None:
            await ctx.send("You didn't mention anyone!")
        
        else:
            await ctx.send(target.mention)
    #whatever other code
    

    so it's target:discord.Member = None instead of target:discord.Member == None and that async def thingy ofcourse :)