Jack Thorn
Jack Thorn

Reputation: 67

Discord.py mentioning mentioned user

I'm trying to make a "!welcome (mention member)" command, which will then send a predefined message, tagging the member I mentioned. I want it to look like this, if for example, I typed "!welcome @Elastic_Disaster" --> https://gyazo.com/8e055cd380f0dd1e608c77f590ce631c

This is the code I've tried, but it does nothing.

@bot.command()
@commands.has_permissions(administrator=True)
async def welcome (ctx, user = discord.Member):
    member = str(ctx.member)
    await ctx.send(f'{member} welcome to the server (and more welcome stuff here).')

Upvotes: 0

Views: 115

Answers (1)

Nurqm
Nurqm

Reputation: 4743

If you want to specify a argument's class, you have to use : instead of =. Then, you can use discord.Member.mention to mention the member.

@bot.command()
@commands.has_permissions(administrator=True)
async def welcome (ctx, user: discord.Member):
    await ctx.send(f'{user.mention} welcome to the server (and more welcome stuff here).')

Upvotes: 1

Related Questions