-1

https://i.stack.imgur.com/QaZh7.png Discord.py how to mention/show the username of someone who used the command? As you can see in the image it says "you cleared ... messages". I want it to say "@Jonathan#9999" or "Jonathan" cleared ... messages. how do I do it? how do I mention someone that used the command?

Example of what I want - https://i.stack.imgur.com/m4HNp.png.

What it does now - https://i.stack.imgur.com/QaZh7.png.

--That's my code--

@client.command(name='clear')
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=5,):
    await ctx.channel.purge(limit=amount)
    Embed = discord.Embed(title = '✅ Success!', description=f'cleared {amount} messages!', color = 0x00ff00)
    await ctx.message.channel.send(embed=Embed)

1 Answers1

1
@client.command(name='clear')
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=5,):
        await ctx.channel.purge(limit=amount)
        Embed = discord.Embed(title = '✅ Success!', 
        description=f'{ctx.author.mention} cleared {amount} messages!', color = 0x00ff00)
        await ctx.message.channel.send(embed=Embed)

I've tested the code, it's working :)

Example

Taufeeq Riyaz
  • 111
  • 1
  • 8