1
0
Fork 0

Remove warns from database when leave a guild

This commit is contained in:
Ethanell 2020-08-02 18:46:15 +02:00
parent cf4b03c21c
commit 8a2d86870c

View file

@ -1,6 +1,6 @@
import re
from discord import Embed, Forbidden, Member
from discord import Embed, Forbidden, Member, Guild
from discord.ext import commands
from discord.ext.commands import BadArgument
@ -105,6 +105,14 @@ class Warn(commands.Cog):
await ctx.send(embed=embed)
@commands.Cog.listener()
async def on_guild_remove(self, guild: Guild):
s = db.Session()
for w in s.query(db.Warn).filter(db.Warn.guild == guild.id).all():
s.delete(w)
s.commit()
s.close()
def setup(bot):
logger.info(f"Loading...")