changed type
variable to moderation_type
in mysql_log
This commit is contained in:
parent
b615b258c2
commit
66b232781e
1 changed files with 7 additions and 7 deletions
|
@ -20,17 +20,17 @@ class Moderation(commands.Cog):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
disable_dateutil()
|
disable_dateutil()
|
||||||
|
|
||||||
def insert_to_moddb(self, type, target_id, duration, reason):
|
def mysql_log(self, moderation_type, target_id, duration, reason):
|
||||||
moddb = mysql.connector.connect(host=db_host,user=db_user,password=db_password,database=db)
|
moddb = mysql.connector.connect(host=db_host,user=db_user,password=db_password,database=db)
|
||||||
cursor = moddb.cursor()
|
cursor = moddb.cursor()
|
||||||
cursor.execute("SELECT moderation_id FROM `mod` ORDER BY moderation_id DESC LIMIT 1")
|
cursor.execute("SELECT moderation_id FROM `mod` ORDER BY moderation_id DESC LIMIT 1")
|
||||||
moderation_id = cursor.fetchone()[0] + 1
|
moderation_id = cursor.fetchone()[0] + 1
|
||||||
sql = "INSERT INTO `mod` (moderation_id, moderation_type, target_id, duration, reason, resolved) VALUES (%s, %s, %s, %s, %s, %s)"
|
sql = "INSERT INTO `mod` (moderation_id, moderation_type, target_id, duration, reason, resolved) VALUES (%s, %s, %s, %s, %s, %s)"
|
||||||
val = (moderation_id, type, target_id, duration, reason, 0)
|
val = (moderation_id, moderation_type, target_id, duration, reason, 0)
|
||||||
cursor.execute(sql, val)
|
cursor.execute(sql, val)
|
||||||
moddb.commit()
|
moddb.commit()
|
||||||
moddb.close()
|
moddb.close()
|
||||||
print(f"MySQL Row Inserted!\n{moderation_id}, {type}, {target_id}, {duration}, {reason}, 0")
|
print(f"MySQL Row Inserted!\n{moderation_id}, {moderation_type}, {target_id}, {duration}, {reason}, 0")
|
||||||
|
|
||||||
@commands.command(name="timeout", aliases=["mute"])
|
@commands.command(name="timeout", aliases=["mute"])
|
||||||
async def timeout(self, ctx: commands.Context, target: commands.MemberConverter, duration: str, *, reason: str):
|
async def timeout(self, ctx: commands.Context, target: commands.MemberConverter, duration: str, *, reason: str):
|
||||||
|
@ -43,7 +43,7 @@ class Moderation(commands.Cog):
|
||||||
await ctx.message.reply(f"{target.mention} has been timed out for {str(parsed_time)}!\n**Reason** - `{reason}`")
|
await ctx.message.reply(f"{target.mention} has been timed out for {str(parsed_time)}!\n**Reason** - `{reason}`")
|
||||||
# embeds = [revolt.SendableEmbed(title="Timed Out", description=f"You have been timed out for {str(parsed_time)}.\n### Reason\n`{reason}", colour="#5d82d1")]
|
# embeds = [revolt.SendableEmbed(title="Timed Out", description=f"You have been timed out for {str(parsed_time)}.\n### Reason\n`{reason}", colour="#5d82d1")]
|
||||||
# await target.send(embeds=embeds)
|
# await target.send(embeds=embeds)
|
||||||
Moderation.insert_to_moddb(self, type='Timeout', target_id=target.id, duration=parsed_time, reason=reason)
|
Moderation.mysql_log(self, type='Timeout', target_id=target.id, duration=parsed_time, reason=reason)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def warn(self, ctx: commands.Context, target: commands.MemberConverter, *, reason: str):
|
async def warn(self, ctx: commands.Context, target: commands.MemberConverter, *, reason: str):
|
||||||
|
@ -53,7 +53,7 @@ class Moderation(commands.Cog):
|
||||||
await ctx.message.reply(f"{target.mention} has been warned!\n**Reason** - `{reason}`")
|
await ctx.message.reply(f"{target.mention} has been warned!\n**Reason** - `{reason}`")
|
||||||
# embeds = [revolt.SendableEmbed(title="Warned", description=f"You have been warned.\n### Reason\n`{reason}", colour="#5d82d1")]
|
# embeds = [revolt.SendableEmbed(title="Warned", description=f"You have been warned.\n### Reason\n`{reason}", colour="#5d82d1")]
|
||||||
# await target.send(embeds=embeds)
|
# await target.send(embeds=embeds)
|
||||||
Moderation.insert_to_moddb(self, type='Warning', target_id=target.id, duration='NULL', reason=reason)
|
Moderation.mysql_log(self, type='Warning', target_id=target.id, duration='NULL', reason=reason)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def ban(self, ctx: commands.Context, target: commands.MemberConverter, *, reason: str):
|
async def ban(self, ctx: commands.Context, target: commands.MemberConverter, *, reason: str):
|
||||||
|
@ -65,7 +65,7 @@ class Moderation(commands.Cog):
|
||||||
# await target.send(embeds=embeds)
|
# await target.send(embeds=embeds)
|
||||||
await target.ban(reason=reason)
|
await target.ban(reason=reason)
|
||||||
await ctx.message.reply(f"{target.mention} has been banned!\n**Reason** - `{reason}`")
|
await ctx.message.reply(f"{target.mention} has been banned!\n**Reason** - `{reason}`")
|
||||||
Moderation.insert_to_moddb(self, type='Ban', target_id=target.id, duration='NULL', reason=reason)
|
Moderation.mysql_log(self, type='Ban', target_id=target.id, duration='NULL', reason=reason)
|
||||||
except revolt.errors.HTTPError:
|
except revolt.errors.HTTPError:
|
||||||
await ctx.message.reply(f"{target.mention} is already banned!")
|
await ctx.message.reply(f"{target.mention} is already banned!")
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class Moderation(commands.Cog):
|
||||||
# embeds = [revolt.SendableEmbed(title="Unbanned", description="You have been unbanned.", colour="#5d82d1")]
|
# embeds = [revolt.SendableEmbed(title="Unbanned", description="You have been unbanned.", colour="#5d82d1")]
|
||||||
# await target.send(embeds=embeds)
|
# await target.send(embeds=embeds)
|
||||||
await ctx.message.reply(f"{target.mention} has been unbanned!")
|
await ctx.message.reply(f"{target.mention} has been unbanned!")
|
||||||
Moderation.insert_to_moddb(self, type='Unban', target_id=target.id, duration='NULL', reason=f'Unbanned through {prefix}unban')
|
Moderation.mysql_log(self, type='Unban', target_id=target.id, duration='NULL', reason=f'Unbanned through {prefix}unban')
|
||||||
except revolt.errors.HTTPError:
|
except revolt.errors.HTTPError:
|
||||||
await ctx.message.reply(f"{target.mention} is not banned!")
|
await ctx.message.reply(f"{target.mention} is not banned!")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue