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

472 views Asked by At

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)

2

There are 2 answers

0
SYCK playz On BEST ANSWER

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 :)

3
NastyCore On

(This is my first reply aswell!)

so lets say

import discord
from discord.ext import commands #or command I can't remember)

#setup setting(on_ready.. etc)

@client.command(ctx, target:discord.Member == None) #CTX represents your command, target means your mentioned member

if target == None:
    await ctx.send("You didn't mention anyone!")
else:
    await ctx.send(target.mention)

#client run token