if message.content.startswith('$register'):
await message.channel.send('You are registered successfully')
userk = print(client.user.id)
I am using Discord.py and Iam trying to get the Discord user id of a user when they type into a channel. But I am not able to find the specific command for that current api of discord is not saying anything about that.the above code is only printing my bot’s id.
>Solution :
Get the author of the message
You need to look the id of the author.
API:
- discord.on_message(message): Get a message, a Message,
- class discord.Message: look for author attribute, a Member,
- class discord.Member: look id attribute.
if message.content.startswith('$register'):
await message.channel.send('You are registered successfully')
print(message.author.id)