Q
Q
Quaasaar2020-05-11 11:02:20
Python
Quaasaar, 2020-05-11 11:02:20

Discord.py how to change server icon with bot command?

I have a code that changes the server name:

@bot.command()
async def rename(ctx):
    await ctx.message.delete()
    guild = ctx.message.guild
    await guild.edit(name='Testing', icon='Тут должна быть ссылка на изображение')
But when I insert a link to an image in the corresponding field, the code returns an error:
spoiler
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes
How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PorovozBoris, 2020-05-11
@Quaasaar

with open('image.jpg', 'rb') as f:
    icon = f.read()
await bot.edit_guild(ctx.message.guild, icon=icon)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question