Answer the question
In order to leave comments, you need to log in
How to get basic user data in discord?
I just started making my new Discord bot today. I keep a log.
Problem: I can't get the sender of a message (no matter what). That is, who where and at what time sent a message or link. The structure of my code looks something like this:
@bot.command() #Метод для каждой команды для бота
async def start_message(ctx): #Приветственное сообщение
author = ctx.message.author
await ctx.send(f'{author.mention}, привет!') #Здесь я могу получить имя пользователя, но вне функции я этого сделать не могу, именно в этом проблема.
@bot.command()
async def hello_message(ctx):#Ещё команда
author = ctx.message.author
embed = discord.Embed(color=654321, title=f'Привет, {author}!!') #Эмбед сообщение
embed.set_image(url='https://avatars.mds.yandex.net/get-pdb/1390202/3d87c5f7-dbe3-46db-b73e-a1c59ca88e37/s1200')
await ctx.send(embed = embed)
@bot.command()
async def ilovemyfamily(ctx):
embed = discord.Embed(color=654321, title=f'Хабр топ')
embed.set_image(url='https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Heart_coraz%C3%B3n.svg/800px-Heart_coraz%C3%B3n.svg.png')
await ctx.send(embed = embed)
Answer the question
In order to leave comments, you need to log in
@bot.listen()
async def on_message(message):
member = message.author
name = member.name
discriminator = member.discriminator #Это непосредственно ID(#????) - четыре цифры на конце имени
nick = member.nick
text = message
# далее записываете переменные туда, куда вам нужно
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question