Combining botlists and statcord into one

pull/9/head
sgoudham 4 years ago
parent 7587d41851
commit 6df436a78d

@ -16,9 +16,11 @@
import aiohttp import aiohttp
import dbl import dbl
import statcord
from decouple import config from decouple import config
from discord.ext import commands, tasks from discord.ext import commands, tasks
statcord_auth = config("STATCORD_AUTH")
disforge_auth = config('DISFORGE_AUTH') disforge_auth = config('DISFORGE_AUTH')
disc_bots_gg_auth = config('DISCORD_BOTS_BOTS_AUTH') disc_bots_gg_auth = config('DISCORD_BOTS_BOTS_AUTH')
top_gg_auth = config('TOP_GG_AUTH') top_gg_auth = config('TOP_GG_AUTH')
@ -37,16 +39,17 @@ async def post_bot_stats(self):
data={"servers": {len(self.guilds)}}, data={"servers": {len(self.guilds)}},
headers={'Authorization': disforge_auth}) headers={'Authorization': disforge_auth})
await session.close()
class BotLists(commands.Cog):
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API""" """Handles interactions with the top.gg API"""
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
self.token = top_gg_auth self.token = top_gg_auth
self.dblpy = dbl.DBLClient(self.bot, self.token) self.dblpy = dbl.DBLClient(self.bot, self.token)
self.key = f"statcord.com-{statcord_auth}"
self.api = statcord.Client(self.bot, self.key)
self.api.start_loop()
@tasks.loop(minutes=30, reconnect=True) @tasks.loop(minutes=30, reconnect=True)
async def post_updates(): async def post_updates():
@ -65,6 +68,10 @@ class TopGG(commands.Cog):
# Start the background task(s) # Start the background task(s)
post_updates.start() post_updates.start()
@commands.Cog.listener()
async def on_command(self, ctx):
self.api.command_run(ctx)
def setup(bot): def setup(bot):
bot.add_cog(TopGG(bot)) bot.add_cog(BotLists(bot))

Loading…
Cancel
Save