xxxxxxxxxx
id = message.author.id
await message.channel.send("<@"+str(id)+"> Mentioned you!")
xxxxxxxxxx
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
print(message.author.id)
client.run('token')
xxxxxxxxxx
import discord
import asyncio
client = discord.Client()
@client.event
async def on_message(message):
print(message.author.id)
client.run('token')
xxxxxxxxxx
#Another way to do it as a simpler way with discord.py:
#(This is a command for showing the author of the message's ID)
id = message.author.id
if message.content.startswith("!whatismyid"):
await message.channel.send("Your ID is: "+str(id))
xxxxxxxxxx
import discord.utils
# within a command
user = discord.utils.get(ctx.guild.members, name='Username')