misc(moderation): changed table naming scheme
This commit is contained in:
parent
2b0e24a4e9
commit
6fba47ea56
1 changed files with 8 additions and 8 deletions
|
@ -5,7 +5,7 @@ import discord
|
|||
import humanize
|
||||
import mysql.connector
|
||||
from pytimeparse2 import disable_dateutil, parse
|
||||
from redbot.core import Config, checks, commands
|
||||
from redbot.core import Config, checks, commands, tasks
|
||||
|
||||
|
||||
class Moderation(commands.Cog):
|
||||
|
@ -115,11 +115,11 @@ class Moderation(commands.Cog):
|
|||
database = await self.connect()
|
||||
cursor = database.cursor()
|
||||
try:
|
||||
cursor.execute(f"SELECT * FROM `{guild.id}_moderation`")
|
||||
cursor.execute(f"SELECT * FROM `moderation_{guild.id}`")
|
||||
logging.info("MySQL Table exists for server %s (%s)", guild.name, guild.id)
|
||||
except mysql.connector.errors.ProgrammingError:
|
||||
query = f"""
|
||||
CREATE TABLE `{guild.id}_moderation` (
|
||||
CREATE TABLE `moderation_{guild.id}` (
|
||||
moderation_id INT UNIQUE PRIMARY KEY NOT NULL,
|
||||
timestamp INT NOT NULL,
|
||||
moderation_type LONGTEXT NOT NULL,
|
||||
|
@ -135,7 +135,7 @@ class Moderation(commands.Cog):
|
|||
"""
|
||||
cursor.execute(query)
|
||||
insert_query = f"""
|
||||
INSERT INTO `{guild.id}_moderation`
|
||||
INSERT INTO `moderation_{guild.id}`
|
||||
(moderation_id, timestamp, moderation_type, target_id, moderator_id, duration, end_timestamp, reason, resolved, resolve_reason, expired)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
"""
|
||||
|
@ -143,7 +143,7 @@ class Moderation(commands.Cog):
|
|||
cursor.execute(insert_query, insert_values)
|
||||
database.commit()
|
||||
database.close()
|
||||
logging.info("MySQL Table created for %s (%s)\n%s_moderation", guild.name, guild.id, guild.id)
|
||||
logging.info("MySQL Table created for %s (%s)\nmoderation_%s", guild.name, guild.id, guild.id)
|
||||
else:
|
||||
database.close()
|
||||
return
|
||||
|
@ -165,14 +165,14 @@ class Moderation(commands.Cog):
|
|||
end_timestamp = 0
|
||||
database = await self.connect()
|
||||
cursor = database.cursor()
|
||||
cursor.execute(f"SELECT moderation_id FROM `{guild_id}_moderation` ORDER BY moderation_id DESC LIMIT 1")
|
||||
cursor.execute(f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1")
|
||||
moderation_id = cursor.fetchone()[0] + 1
|
||||
sql = f"INSERT INTO `{guild_id}_moderation` (moderation_id, timestamp, moderation_type, target_id, moderator_id, duration, end_timestamp, reason, resolved, resolve_reason, expired) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||
sql = f"INSERT INTO `moderation_{guild_id}` (moderation_id, timestamp, moderation_type, target_id, moderator_id, duration, end_timestamp, reason, resolved, resolve_reason, expired) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||
val = (moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, f"{reason}", 0, "NULL", 0)
|
||||
cursor.execute(sql, val)
|
||||
database.commit()
|
||||
database.close()
|
||||
logging.debug("MySQL row inserted into %s_moderation!\n%s, %s, %s, %s, %s, %s, %s, %s, 0, NULL", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, reason)
|
||||
logging.debug("MySQL row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, 0, NULL", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, reason)
|
||||
|
||||
@commands.hybrid_command(name="mute", aliases=['timeout'])
|
||||
@commands.mod()
|
||||
|
|
Loading…
Reference in a new issue