Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I am trying to make a discord bot in which I want that as soon as user type into command channel his/her discord id must be printed

 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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Get the author of the message

You need to look the id of the author.

API:

if message.content.startswith('$register'):
    await message.channel.send('You are registered successfully')
    print(message.author.id)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading