Answer the question
In order to leave comments, you need to log in
How to get user's profile picture in discord.py?
I wanted to get the user's avatar, but the following error pops up:
async def warn(ctx, member: discord.Member, time: int, reason = None):
role = discord.utils.get(ctx.guild.roles, id=warnrole)
await member.add_roles(role)
channel = Bot.get_channel(logchannel)
emb = discord.Embed(title="Предупреждение", color=0x2f3136)
emb.set_thumbnail(url=member.avatar_url)
emb.add_field(name='Модератор', value=ctx.message.author.mention, inline=False)
emb.add_field(name='Нарушитель', value=member.mention, inline=False)
emb.add_field(name='Причина', value=reason, inline=False)
emb.add_field(name="Время", value=time, inline=False)
await channel.send(embed = emb)
Answer the question
In order to leave comments, you need to log in
And, that's it, the problem is solved, it is necessary to emb.set_thumbnail(url=member.avatar_url)
use not 'avatar_url,' but 'avatar'. Might help someone :)
async def warn(ctx, member: discord.Member, time: int, reason = None, user: discord.User = None):
if user is None:
user = ctx.author
role = discord.utils.get(ctx.guild.roles, id = warnrole)
await member.add_roles(role)
channel = Bot.get_channel(logchannel)
emb = discord.Embed(title = "Предупреждение", color = 0x2f3136)
emb.set_thumbnail(url = user.avatar_url)
emb.add_field(name = 'Модератор', value = ctx.message.author.mention, inline = False)
emb.add_field(name = 'Нарушитель', value = member.mention, inline = False)
emb.add_field(name = 'Причина', value = reason, inline = False)
emb.add_field(name = "Время", value = time, inline = False)
await channel.send(embed = emb)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question