I'm making a discord bot with Python and I want to send an embed when the use use the command ]kill .So when I tag someone and use the command the output is not the member name.
I need to make it the tagged user's name.
This is my code.
killgifs = ['https://c.tenor.com/1dtHuFICZF4AAAAC/kill-smack.gif' , 'https://c.tenor.com/gQAWuiZnbZ4AAAAC/pokemon-anime.gif' , 'https://c.tenor.com/PJbU0yjG3BUAAAAd/anime-girl.gif' , 'https://c.tenor.com/Re9dglY0sCwAAAAC/anime-wasted.gif']
@bot.command(name='kill')
async def kill (ctx,person) :
author = ctx.author
embed = discord.Embed (color=discord.Color.red())
embed.set_author(name=f'{author} kills {person}')
embed.set_image(url = (random.choice(killgifs)))
await ctx.send(embed=embed)
You can work with discord.Member
here since you can't mention a person in an embed title/author field. Simply change your code to the following:
killgifs = ['https://c.tenor.com/1dtHuFICZF4AAAAC/kill-smack.gif',
'https://c.tenor.com/gQAWuiZnbZ4AAAAC/pokemon-anime.gif',
'https://c.tenor.com/PJbU0yjG3BUAAAAd/anime-girl.gif',
'https://c.tenor.com/Re9dglY0sCwAAAAC/anime-wasted.gif']
@bot.command(name='kill')
async def kill(ctx, person: discord.Member): # Make the person a discord.Member
author = ctx.author
embed = discord.Embed(color=discord.Color.red())
embed.set_author(name=f'{author} kills {person.display_name}') # Display the name
embed.set_image(url=(random.choice(killgifs)))
await ctx.send(embed=embed)