def update_dbots(self):
if not discord_bots_token:
self.logger.warning('Tried to contact Discord Bots, but no token set!')
return False
data = dict(guild_count=len(self.bot.guilds))
dest = 'https://bots.discord.pw/api/bots/' + str(self.bot.user.id) + '/stats'
headers = {
'Authorization': discord_bots_token,
'Content-Type': 'application/json'
}
with async_timeout.timeout(6):
async with self.bot.cog_http.post(dest, data=json.dumps(data), headers=headers) as r:
resp_key = f'(got {r.status} {r.reason})'
if r.status == 200:
self.logger.info('Successfully sent Discord Bots our guild count (got 200 OK)')
else:
self.logger.warning('Failed sending our guild count to Discord Bots! ' + resp_key)
评论列表
文章目录