T
T
Tim Novikov2021-08-16 11:55:53
Python
Tim Novikov, 2021-08-16 11:55:53

How to get server avatar using discord.py?

@bot.command(pass_context = True)
@commands.has_role("Admin")
async def kick(ctx, member: discord.Member,*,reason = None):
    await ctx.message.delete()
    emb = discord.Embed(title="Выгнан с сервера", description = "Причина: {}".format(reason), colour=discord.Color.orange(), )
    emb.set_author(name = member.name, icon_url= member.avatar_url)
    await member.kick(reason = reason)
    await ctx.send(embed=emb)

    own_emb = discord.Embed(title="Вы были выгнаны с сервера", description="Причина: {}".format(reason),colour=discord.Color.orange(), )
    own_emb.set_author(name=member.name, icon_url=member.avatar_url)
    own_emb.set_footer(text=str(ctx.message.guild.name), icon_url=" Аватар сервера ")
    await member.send(embed = own_emb)

in the second half of the code, the bot sends a private message to the user who was kicked by the admin, in it I want to additionally specify the name and Avatar of the server, everything is ok with the name, but there are problems with the Avatar.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Mokhovikov, 2021-08-16
@Tim_1527

Try this

own_emb.set_footer(text=str(ctx.message.guild.name), icon_url=guild.avatar_url)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question