Add Guild Events
This commit is contained in:
parent
f889f5a26a
commit
f25290ebee
1
bot.py
1
bot.py
@ -6,6 +6,7 @@ import aiohttp
|
|||||||
import asyncpg
|
import asyncpg
|
||||||
from concurrent import futures
|
from concurrent import futures
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
log_format = '{asctime}.{msecs:03.0f}|{levelname:<8}|{name}::{message}'
|
log_format = '{asctime}.{msecs:03.0f}|{levelname:<8}|{name}::{message}'
|
||||||
date_format = '%Y.%m.%d %H.%M.%S'
|
date_format = '%Y.%m.%d %H.%M.%S'
|
||||||
|
|||||||
23
exts/events.py
Normal file
23
exts/events.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import discord
|
||||||
|
import logging
|
||||||
|
|
||||||
|
events_log = logging.getLogger('events')
|
||||||
|
|
||||||
|
|
||||||
|
class BotEvents:
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
async def on_guild_join(self, guild):
|
||||||
|
await self.bot.db_con.execute("insert into guild_config(guild_id, channel_lockdown) values ($1, $2)",
|
||||||
|
guild.id, False)
|
||||||
|
events_log.info(f'Entry Created for {guild.name}')
|
||||||
|
await guild.me.edit(nick='[!] Submitter')
|
||||||
|
|
||||||
|
async def on_guild_remove(self, guild):
|
||||||
|
await self.bot.db_con.execute(f'delete from guild_config where guild_id = $1', guild.id)
|
||||||
|
events_log.info(f'Left the {guild.name} guild.')
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(BotEvents(bot))
|
||||||
Loading…
x
Reference in New Issue
Block a user