Reputation: 3
Every day I change the nickname of the bot, but how to change its avatar, I found discord.py documentation
avatar (bytes) - A bytes-like object representing the image to upload. Could be None to denote no avatar.
But I don’t even understand how to use it, and yes, I know, I’m an xD kettle
Help please
Upvotes: 0
Views: 1883
Reputation: 60944
This is discussed in the documentation for ClientUser.edit
:
Note
To upload an avatar, a bytes-like object must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via open('some_filename', 'rb') and the bytes-like object is given through the use of fp.read().
The only image formats supported for uploading is JPEG and PNG.
So you would do something like
with open(path_to_file, 'rb') as f:
image = f.read()
await bot.user.edit(avatar=image)
Upvotes: 1