Last active
August 9, 2017 04:05
-
-
Save ioistired/5acd66460be44ce2fa7281953d3c700e to your computer and use it in GitHub Desktop.
Update your bot stats with bots.discord.pw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for discord.py users | |
async def update_bot_stats(): | |
"""inform bots.discord.pw of how many guilds the bot is in""" | |
async with aiohttp.ClientSession() as session: | |
print('Updating stats.') | |
print('Server count:', str(len(bot.servers))) | |
print('Auth token:', bot.discordpw_api_token) | |
print('Sending', '{{"server_count": {}}}'.format(len(bot.servers))) | |
async with session.post( | |
'https://bots.discord.pw/api/bots/{}/stats'.format(bot.user.id), | |
# manually format as JSON | |
# pfft, who needs `json.dumps()`? | |
data='{{"server_count": {}}}'.format(len(bot.servers)), | |
headers={ | |
'Authorization': bot.discordpw_api_token, | |
'Content-Type': 'application/json', | |
}, | |
) as resp: | |
print(await resp.text()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment