feat(moderation): added support for data deletion requests
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 46s
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 46s
This commit is contained in:
parent
1d9114e19b
commit
9380143d04
1 changed files with 28 additions and 0 deletions
|
@ -23,6 +23,34 @@ class Moderation(commands.Cog):
|
|||
"""Custom moderation cog.
|
||||
Developed by SeaswimmerTheFsh."""
|
||||
|
||||
async def red_delete_data_for_user(self, *, requester, user_id: int):
|
||||
if requester == "discord_deleted_user":
|
||||
await self.config.user_from_id(user_id).clear()
|
||||
|
||||
database = await self.connect()
|
||||
cursor = database.cursor()
|
||||
|
||||
cursor.execute("SHOW TABLES;")
|
||||
tables = [table[0] for table in cursor.fetchall()]
|
||||
|
||||
condition = "target_id = %s OR moderator_id = %s;"
|
||||
|
||||
for table in tables:
|
||||
delete_query = f"DELETE FROM {table[0]} WHERE {condition}"
|
||||
cursor.execute(delete_query, (user_id, user_id))
|
||||
|
||||
database.commit()
|
||||
cursor.close()
|
||||
database.close()
|
||||
if requester == "owner":
|
||||
await self.config.user_from_id(user_id).clear()
|
||||
if requester == "user":
|
||||
await self.config.user_from_id(user_id).clear()
|
||||
if requester == "user_strict":
|
||||
await self.config.user_from_id(user_id).clear()
|
||||
else:
|
||||
self.logger.warning("Invalid requester passed to red_delete_data_for_user: %s", requester)
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.config = Config.get_conf(self, identifier=481923957134912)
|
||||
|
|
Loading…
Reference in a new issue