pluralsync/updatediscordavatar.py

25 lines
647 B
Python

#!/usr/bin/env python3
import os
import json
import discord
config_dir = os.getenv('APPDATA') if os.name == "nt" else os.path.expanduser('~') + "/.config"
config_dir += "/pluralsync/config.json"
f = open(config_dir)
json = json.load(f)
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
avatar_path = json["avatar_module"]["avatar_output_path"]
fp = open(avatar_path, 'rb')
avatar = fp.read()
await self.user.edit(avatar=avatar)
print('Discord module finished')
await self.close()
client = MyClient()
client.run(json["disc_module"]["token"])