JustDelete the message instead of iterating during guild remove

This commit is contained in:
Jeremy Zhang 2018-03-25 05:57:00 +00:00
parent 4859b5a379
commit c35743b498

View File

@ -152,9 +152,7 @@ class DatabaseInterface(object):
with self.get_session() as session: with self.get_session() as session:
gui = session.query(Guilds).filter(Guilds.guild_id == int(guild.id)).first() gui = session.query(Guilds).filter(Guilds.guild_id == int(guild.id)).first()
if gui: if gui:
dbmsgs = session.query(Messages).filter(Messages.guild_id == int(guild.id)).all() dbmsgs = session.query(Messages).filter(Messages.guild_id == int(guild.id)).delete()
for msg in dbmsgs:
session.delete(msg)
session.delete(gui) session.delete(gui)
session.commit() session.commit()