Jump to content

Can someone help me mention the user that ran the command in discord.py?

TheCoder2019
Go to solution Solved by remuff,

If you have the context, you can just find the author of the message with ctx.message.author (or just ctx.author since rewrite).

So you can just mention the user with something like the following:

@bot.commmand()
async def mention_me(ctx: commands.Context):
	"""Simply mentions the author of the command in a message"""
    await ctx.send(f"Hello {ctx.author.mention}, your muffins look great today!")

 

I have tried so many methods, like

Spoiler


{user.mention}
{message.user.mention}
{author.mention}
{ctx.author.mention}

 

and nothing seems to work. I am trying to mention with ID, here's what I tried:

uid =  client.get_user_info(id)
   await ctx.send(f"Hey, <@uid>!")

What am I doing wrong? I have the decorator and stuff, but it spits out a ton of errors, and fills the whole console to where old logs can't be scrolled up to

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

If you have the context, you can just find the author of the message with ctx.message.author (or just ctx.author since rewrite).

So you can just mention the user with something like the following:

@bot.commmand()
async def mention_me(ctx: commands.Context):
	"""Simply mentions the author of the command in a message"""
    await ctx.send(f"Hello {ctx.author.mention}, your muffins look great today!")

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×