Discord.py: How to set a new Avatar?

Created on 15 Apr 2016  路  3Comments  路  Source: Rapptz/discord.py

Hello,
I tried to my best effort to set an avatar with the edit_profile function. But i am just unable to get things rolling... My current guess is that i don't call it in the right position.

My try is:

@client.event
async def on_message(message):
if message.content.startswith('!wat'):
fp = open('avatar_256.jpg', 'rb')
l = {
"avatar": fp.read()
}
await client.edit_profile(None, l)

The error i get is:

Traceback (most recent call last):
File "\client.py", line 267, in _run_event
yield from getattr(self, event)(_args, *_kwargs)
File "/bot.py", line 31, in on_message
await client.edit_profile(None, l)
TypeError: edit_profile() takes from 1 to 2 positional arguments but 3 were given

But i just don't understand why it says it was to many arguments. I set two, password and my list, which are required - and self was assigned automatically. This are exactly three arguments which are intended for this function.

I bet it's a plain stupid mistake. Any help is appreciated. :)

Most helpful comment

with open('some_image.jpg', 'rb') as f:
    await client.edit_profile(avatar=f.read())

All 3 comments

with open('some_image.jpg', 'rb') as f:
    await client.edit_profile(avatar=f.read())

does the image has to be .png?

Please don't necro bump issues, no the image does not have to be a png.

You can also think about joining the discord server for questions like this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzburda picture jzburda  路  3Comments

Rimmy50 picture Rimmy50  路  3Comments

Spyder-exe picture Spyder-exe  路  3Comments

adhoc92 picture adhoc92  路  3Comments

j0hnmeow picture j0hnmeow  路  3Comments