Z
Z
Zac Rider2020-12-15 14:56:04
Python
Zac Rider, 2020-12-15 14:56:04

Mention a person via discord.py?

Good day! I apologize in advance, but I'm probably too blind to find a solution to this problem. The fact is that, as I understand it, there was an update to discrod.py sometime there and now my bot cannot display the person's name. Please help and tell me what needs to be fixed?

I don’t throw off all the code, since everything is standard there, the problem appears in this line:

author = bot.get_user(my_user_id)
await message_channel.send(f'@{author} - Welcome back!')

It displays -> @None - Welcome back!

Before that, as you can understand, he displayed the nickname of a person

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-12-15
@b00tyCha1n

Make sure you are passing in get_userID in int.

author = bot.get_user(int(my_user_id))
await message_channel.send(f'{author.mention} - Welcome back!')

Also remember that it get_usergets data from the bot's cache, and intents are needed to fill it
. Otherwise, you can build the mention manually:
await message_channel.send(f'<@{my_user_id}> - Welcome back!')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question