Remove warns from database when leave a guild
This commit is contained in:
parent
cf4b03c21c
commit
8a2d86870c
1 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from discord import Embed, Forbidden, Member
|
from discord import Embed, Forbidden, Member, Guild
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import BadArgument
|
from discord.ext.commands import BadArgument
|
||||||
|
|
||||||
|
@ -105,6 +105,14 @@ class Warn(commands.Cog):
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
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):
|
def setup(bot):
|
||||||
logger.info(f"Loading...")
|
logger.info(f"Loading...")
|
||||||
|
|
Reference in a new issue