mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 14:37:02 +01:00
Update cleanup db messages to message id
This commit is contained in:
parent
a0edd06d36
commit
d438b6d34f
@ -76,7 +76,7 @@ class Titan(discord.Client):
|
||||
count = 0
|
||||
for guild in guilds:
|
||||
count += 1
|
||||
print("[{}] id-{} snowflake-{} name-{}".format(count, guild.id, guild.guild_id, guild.name))
|
||||
print("[{}] snowflake-{} name-{}".format(count, guild.guild_id, guild.name))
|
||||
try:
|
||||
channelsjson = json.loads(guild.channels)
|
||||
except:
|
||||
@ -85,8 +85,8 @@ class Titan(discord.Client):
|
||||
for channel in channelsjson:
|
||||
chanid = channel["id"]
|
||||
active_channels.append(chanid)
|
||||
keep_these = session.query(Messages.id).filter(Messages.channel_id == chanid).order_by(Messages.timestamp.desc()).limit(50)
|
||||
d = session.query(Messages).filter(Messages.channel_id == chanid, ~Messages.id.in_(keep_these)).delete(synchronize_session=False)
|
||||
keep_these = session.query(Messages.message_id).filter(Messages.channel_id == chanid).order_by(Messages.timestamp.desc()).limit(50)
|
||||
d = session.query(Messages).filter(Messages.channel_id == chanid, ~Messages.message_id.in_(keep_these)).delete(synchronize_session=False)
|
||||
session.commit()
|
||||
print(" --{} [{}]".format(channel["name"], d))
|
||||
d = session.query(Messages).filter(Messages.guild_id == guild.guild_id, ~Messages.channel_id.in_(active_channels)).delete(synchronize_session=False)
|
||||
@ -102,4 +102,4 @@ def main():
|
||||
gc.collect()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user