简体   繁体   中英

How do i make the bot mention someone just by typing out the user's name without the tag

for example:

me: -mention LOL

Bot: @LOL

You can use member: discord.Member as an required argument.

If you want to mention a user you have to use member.mention .

Here is an example code:

@client.command() # Or whatever you use
async def mention(ctx, member: discord.Member = None): 
    if member == None: # If no argument was passed
        await ctx.send(ctx.author.mention) # Mention the author of the command
    else:
        await ctx.send(member.mention) # Mention the member

Here is how it looks like:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM