mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 06:27:03 +01:00
Delete the messages before fetching new messages
This commit is contained in:
parent
495a08ea12
commit
f46d33c943
@ -6,6 +6,7 @@ import aiohttp
|
|||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
import gc
|
||||||
logging.basicConfig(filename='titanbot.log',level=logging.INFO,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
|
logging.basicConfig(filename='titanbot.log',level=logging.INFO,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
|
||||||
logging.getLogger('TitanBot')
|
logging.getLogger('TitanBot')
|
||||||
logging.getLogger('sqlalchemy')
|
logging.getLogger('sqlalchemy')
|
||||||
@ -72,6 +73,7 @@ class Titan(discord.Client):
|
|||||||
try:
|
try:
|
||||||
if str(channel.type) == "text":
|
if str(channel.type) == "text":
|
||||||
print("Processing channel: ID-{} Name-'{}' ServerID-{} Server-'{}'".format(channel.id, channel.name, channel.server.id, channel.server.name))
|
print("Processing channel: ID-{} Name-'{}' ServerID-{} Server-'{}'".format(channel.id, channel.name, channel.server.id, channel.server.name))
|
||||||
|
await self.database.delete_all_messages_from_channel(channel.id)
|
||||||
async for message in self.logs_from(channel, limit=50, reverse=True):
|
async for message in self.logs_from(channel, limit=50, reverse=True):
|
||||||
await self.database.push_message(message)
|
await self.database.push_message(message)
|
||||||
except:
|
except:
|
||||||
|
@ -287,3 +287,9 @@ class DatabaseInterface(object):
|
|||||||
dbuser.revoked = True
|
dbuser.revoked = True
|
||||||
session.commit()
|
session.commit()
|
||||||
return "Successfully kicked **{}#{}**!".format(dbuser.username, dbuser.discriminator)
|
return "Successfully kicked **{}#{}**!".format(dbuser.username, dbuser.discriminator)
|
||||||
|
|
||||||
|
async def delete_all_messages_from_channel(self, channel_id):
|
||||||
|
async with threadpool():
|
||||||
|
with self.get_session() as session:
|
||||||
|
session.query(Messages).filter(Messages.channel_id == channel_id).delete()
|
||||||
|
session.commit()
|
Loading…
Reference in New Issue
Block a user