Skip to content

Instantly share code, notes, and snippets.

@MrLotU
Last active October 11, 2023 13:54
Show Gist options
  • Save MrLotU/b11d868243062ba9210f4994c1158d43 to your computer and use it in GitHub Desktop.
Save MrLotU/b11d868243062ba9210f4994c1158d43 to your computer and use it in GitHub Desktop.
Changes the profile picture of a discord bot
import discord
#############################################################################################################################
# USAGE: #
# 0. Make sure you have python 3.5 + installed and have discord.py installed (pip3 install discord) #
# 1. Download the python file #
# 2. Change the token variable to hold your bots token and the pfp variable to hold the path to your desired pfp #
# 3. Run your file using `python3 path/to/file.py #
# 3. That's it, you can keep the file or delete it again! #
#############################################################################################################################
client = discord.Client()
token = 'TOKEN HERE'
pfp_path = "path/to/file.png"
fp = open(pfp_path, 'rb')
pfp = fp.read()
@client.event
async def on_ready():
await client.edit_profile(password=None, avatar=pfp)
client.run(token)
@Biganon
Copy link

Biganon commented Nov 4, 2019

For newer versions of the API, line 22 needs to be changed to:

await client.user.edit(avatar=pfp)

(I also removed password=None, since it works without it)

@LouissXI
Copy link

LouissXI commented Dec 7, 2019

Thanks

@meawcafe
Copy link

thanks

@keli5
Copy link

keli5 commented Jun 1, 2020

thanks

@MrLotU
Copy link
Author

MrLotU commented Sep 22, 2020

Hi,
Where i can find bot token, i used Rythm bot for music.
Can i still change its avatar

This only works for bots you own yourself. Not public bots.

@Dapperbot28
Copy link

After using the code more than once, it just says that im 'changing avatar too fast' in an error message.

@bearudev
Copy link

bearudev commented Mar 4, 2021

True. It seems that after you change it once through code it just acts as if you changed it a billion times.

@Bopler
Copy link

Bopler commented May 18, 2023

If you're getting an intents error, change line 12 to:

client = discord.Client(intents=discord.Intents.default())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment