1
+ import requests
2
+ import base64
3
+ from colorama import Fore , Style , Back
4
+
5
+ print (Fore .LIGHTGREEN_EX + """ _______ ______ ________ __
6
+ / \ / \ / | / |
7
+ $$$$$$$ |/$$$$$$ |______ $$$$$$$$/______ ______ $$ |
8
+ $$ |__$$ |$$ |_ $$// \ $$ | / \ / \ $$ |
9
+ $$ $$/ $$ | /$$$$$$ | $$ |/$$$$$$ |/$$$$$$ |$$ |
10
+ $$$$$$$/ $$$$/ $$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ |
11
+ $$ | $$ | $$ |__$$ | $$ |$$ \__$$ |$$ \__$$ |$$ |
12
+ $$ | $$ | $$ $$/ $$ |$$ $$/ $$ $$/ $$ |
13
+ $$/ $$/ $$$$$$$/ $$/ $$$$$$/ $$$$$$/ $$/
14
+ $$ |
15
+ $$ |
16
+ $$/ """ , Style .RESET_ALL )
17
+
18
+
19
+ token = input ("Bot Token: " )
20
+ path_pfp = input ("New animated avatar Path: " )
21
+
22
+ def update_avatar ():
23
+ try :
24
+ with open (path_pfp , 'rb' ) as file :
25
+ new_avatar = file .read ()
26
+
27
+ headers = {
28
+ 'Authorization' : f'Bot { token } ' ,
29
+ 'Content-Type' : 'application/json'
30
+ }
31
+
32
+ avatar_base64 = base64 .b64encode (new_avatar ).decode ('utf-8' )
33
+ body = {
34
+ 'avatar' : f'data:image/gif;base64,{ avatar_base64 } '
35
+ }
36
+
37
+ response = requests .patch ('https://discord.com/api/v9/users/@me' , headers = headers , json = body )
38
+
39
+ if response .ok :
40
+ print (Fore .GREEN , "[+]" , Fore .LIGHTGREEN_EX + 'Avatar updated successfully!' , Style .RESET_ALL )
41
+ print (Fore .GREEN , "[!!!]" , Fore .LIGHTGREEN_EX + 'don\' t forget to leave a star! (https://github.com/Sitois/Pfp-Tool)' , Style .RESET_ALL )
42
+ else :
43
+ print (Fore .RED , "[!]" , Fore .LIGHTRED_EX , 'Failed to update avatar:' , response .status_code )
44
+ print ('Response body:' , response .text , Style .RESET_ALL )
45
+ except Exception as e :
46
+ print (Fore .RED , "[!]" , Fore .LIGHTRED_EX , 'Error while updating avatar:' , e , Style .RESET_ALL )
47
+
48
+ update_avatar ()
0 commit comments