forked from galacticwarrior9/IslamBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TopGG.py
27 lines (19 loc) · 761 Bytes
/
TopGG.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import configparser
import dbl
from discord.ext import commands
config = configparser.ConfigParser()
config.read('config.ini')
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = config['APIs']['top.gg']
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
@commands.Cog.listener()
async def on_guild_join(self, guild): # when the bot joins a server
await self.dblpy.post_guild_count() # post server count
@commands.Cog.listener()
async def on_guild_remove(self, guild): # when the bot leaves a server
await self.dblpy.post_guild_count() # post server count
def setup(bot):
bot.add_cog(TopGG(bot))