Get a name of a user without mentioning them (discord.py)

Seeing as the author is the person that sent the message, you already have their User instance. Because of that, you can just use message.author.name to get their name.

memeEmbed = discord.Embed(title="Meme from {0.author.name}".format(message), color=0x000000)

Also, I’d recommend using Commands instead of manually parsing everything in on_message. I see you doing this:

if message.content.startswith(‘!meme’)

which is unnecessary & will make your code a bit cluttered and hard to maintain if you end up creating more commands. It also doesn’t allow a lot of things like for example aliases (without 90000 if-statements which, again, make your code less readable & maintainable).

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top