diff --git a/extensions/warn.py b/extensions/warn.py index de74ad4..b604d7e 100644 --- a/extensions/warn.py +++ b/extensions/warn.py @@ -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...")