Compare commits
No commits in common. "aca705d07386841a0710b3485162d3a689a85900" and "1ff7f35785571afc187c5e3bc7a3fafdc4d0383e" have entirely different histories.
aca705d073
...
1ff7f35785
1 changed files with 3 additions and 76 deletions
|
@ -6,7 +6,6 @@ import humanize
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
from pytimeparse2 import disable_dateutil, parse
|
from pytimeparse2 import disable_dateutil, parse
|
||||||
from redbot.core import app_commands, checks, Config, commands
|
from redbot.core import app_commands, checks, Config, commands
|
||||||
from redbot.core.app_commands import Choice
|
|
||||||
|
|
||||||
|
|
||||||
class Moderation(commands.Cog):
|
class Moderation(commands.Cog):
|
||||||
|
@ -193,7 +192,7 @@ class Moderation(commands.Cog):
|
||||||
- 'log' - WIP
|
- 'log' - WIP
|
||||||
- 'case' - WIP"""
|
- 'case' - WIP"""
|
||||||
if embed_type == 'message':
|
if embed_type == 'message':
|
||||||
if moderation_type in ["kicked", "banned", "tempbanned", "unbanned"]:
|
if moderation_type in ["kicked", "banned", "unbanned"]:
|
||||||
guild_name = guild.name
|
guild_name = guild.name
|
||||||
else:
|
else:
|
||||||
guild_name = f"[{guild.name}]({response.jump_url})"
|
guild_name = f"[{guild.name}]({response.jump_url})"
|
||||||
|
@ -201,28 +200,13 @@ class Moderation(commands.Cog):
|
||||||
embed_duration = f" for {humanize.precisedelta(duration)}"
|
embed_duration = f" for {humanize.precisedelta(duration)}"
|
||||||
else:
|
else:
|
||||||
embed_duration = ""
|
embed_duration = ""
|
||||||
if moderation_type == "note":
|
embed = discord.Embed(title=str.title(moderation_type), description=f"You have been {moderation_type}{embed_duration} in {guild_name}.", color=await self.bot.get_embed_color(None), timestamp=datetime.now())
|
||||||
embed_desc = "recieved a"
|
|
||||||
else:
|
|
||||||
embed_desc = "been"
|
|
||||||
embed = discord.Embed(title=str.title(moderation_type), description=f"You have {embed_desc} {moderation_type}{embed_duration} in {guild_name}.", color=await self.bot.get_embed_color(None), timestamp=datetime.now())
|
|
||||||
embed.add_field(name='Reason', value=f"`{reason}`")
|
embed.add_field(name='Reason', value=f"`{reason}`")
|
||||||
embed.set_author(name=guild.name, icon_url=guild.icon.url)
|
embed.set_author(name=guild.name, icon_url=guild.icon.url)
|
||||||
embed.set_footer(text=f"Case #{await self.get_next_case_number(guild.id)}", icon_url="https://cdn.discordapp.com/attachments/1070822161389994054/1159469476773904414/arrow-right-circle-icon-512x512-2p1e2aaw.png?ex=65312319&is=651eae19&hm=3cebdd28e805c13a79ec48ef87c32ca532ffa6b9ede2e48d0cf8e5e81f3a6818&")
|
embed.set_footer(text=f"Case #{await self.get_next_case_number(guild.id)}", icon_url="https://cdn.discordapp.com/attachments/1070822161389994054/1159469476773904414/arrow-right-circle-icon-512x512-2p1e2aaw.png?ex=65312319&is=651eae19&hm=3cebdd28e805c13a79ec48ef87c32ca532ffa6b9ede2e48d0cf8e5e81f3a6818&")
|
||||||
return embed
|
return embed
|
||||||
raise(TypeError("'type' argument is invalid!"))
|
raise(TypeError("'type' argument is invalid!"))
|
||||||
|
|
||||||
@app_commands.command(name="note")
|
|
||||||
async def note(self, interaction: discord.Interaction, target: discord.Member, reason: str):
|
|
||||||
"""Add a note to a user."""
|
|
||||||
await interaction.response.send_message(content=f"{target.mention} has recieved a note!\n**Reason** - `{reason}`")
|
|
||||||
try:
|
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'note', await interaction.original_response())
|
|
||||||
await target.send(embed=embed)
|
|
||||||
except discord.errors.HTTPException:
|
|
||||||
pass
|
|
||||||
await self.mysql_log(interaction.guild.id, interaction.user.id, 'NOTE', target.id, 'NULL', reason)
|
|
||||||
|
|
||||||
@app_commands.command(name="warn")
|
@app_commands.command(name="warn")
|
||||||
async def warn(self, interaction: discord.Interaction, target: discord.Member, reason: str):
|
async def warn(self, interaction: discord.Interaction, target: discord.Member, reason: str):
|
||||||
"""Warn a user."""
|
"""Warn a user."""
|
||||||
|
@ -266,7 +250,7 @@ class Moderation(commands.Cog):
|
||||||
if reason:
|
if reason:
|
||||||
await target.timeout(None, reason=f"Unmuted by {interaction.user.id} for: {reason}")
|
await target.timeout(None, reason=f"Unmuted by {interaction.user.id} for: {reason}")
|
||||||
else:
|
else:
|
||||||
await target.timeout(None, reason=f"Unbanned by {interaction.user.id}")
|
await target.timeout(None)
|
||||||
reason = "No reason given."
|
reason = "No reason given."
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`")
|
||||||
try:
|
try:
|
||||||
|
@ -288,63 +272,6 @@ class Moderation(commands.Cog):
|
||||||
await target.kick(f"Kicked by {interaction.user.id} for: {reason}")
|
await target.kick(f"Kicked by {interaction.user.id} for: {reason}")
|
||||||
await self.mysql_log(interaction.guild.id, interaction.user.id, 'KICK', target.id, 'NULL', reason)
|
await self.mysql_log(interaction.guild.id, interaction.user.id, 'KICK', target.id, 'NULL', reason)
|
||||||
|
|
||||||
@app_commands.command(name="ban")
|
|
||||||
@app_commands.choices(answer=[
|
|
||||||
Choice(name="None", value=0),
|
|
||||||
Choice(name='1 Hour', value=3600),
|
|
||||||
Choice(name='12 Hours', value=43200),
|
|
||||||
Choice(name='1 Day', value=86400),
|
|
||||||
Choice(name='3 Days', value=259200),
|
|
||||||
Choice(name='7 Days', value=604800),
|
|
||||||
])
|
|
||||||
async def ban(self, interaction: discord.Interaction, target: discord.User, reason: str, duration: str = None, delete_messages: Choice[int] = 0):
|
|
||||||
"""Ban a user."""
|
|
||||||
try:
|
|
||||||
await interaction.guild.fetch_ban(target.id)
|
|
||||||
await interaction.response.send_message(content=f"{target.mention} is already banned!", ephemeral=True)
|
|
||||||
return
|
|
||||||
except discord.errors.NotFound:
|
|
||||||
pass
|
|
||||||
if duration:
|
|
||||||
try:
|
|
||||||
parsed_time = parse(sval=duration, as_timedelta=True, raise_exception=True)
|
|
||||||
except ValueError:
|
|
||||||
await interaction.response.send_message("Please provide a valid duration!", ephemeral=True)
|
|
||||||
return
|
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been banned for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`")
|
|
||||||
try:
|
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'tempbanned', await interaction.original_response())
|
|
||||||
await target.send(embed=embed)
|
|
||||||
except discord.errors.HTTPException:
|
|
||||||
pass
|
|
||||||
await interaction.guild.ban(target.id, reason=f"Tempbanned by {interaction.user.id} for: {reason} (Duration: {parsed_time})", delete_message_seconds=delete_messages)
|
|
||||||
await self.mysql_log(interaction.guild.id, interaction.user.id, 'TEMPBAN', target.id, parsed_time, reason)
|
|
||||||
else:
|
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been banned!\n**Reason** - `{reason}`")
|
|
||||||
try:
|
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'banned', await interaction.original_response())
|
|
||||||
await target.send(embed=embed)
|
|
||||||
except discord.errors.HTTPException:
|
|
||||||
pass
|
|
||||||
await interaction.guild.ban(target.id, reason=f"Banned by {interaction.user.id} for: {reason}", delete_message_seconds=delete_messages)
|
|
||||||
await self.mysql_log(interaction.guild.id, interaction.user.id, 'BAN', target.id, 'NULL', reason)
|
|
||||||
|
|
||||||
@app_commands.command(name="unban")
|
|
||||||
async def unban(self, interaction: discord.Interaction, target: discord.User, reason: str = None):
|
|
||||||
"""Unban a user."""
|
|
||||||
if reason:
|
|
||||||
await interaction.guild.unban(target.id, reason=f"Unbanned by {interaction.user.id} for: {reason}")
|
|
||||||
else:
|
|
||||||
await interaction.guild.unban(target.id, reason=f"Unbanned by {interaction.user.id}")
|
|
||||||
reason = "No reason given."
|
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been unbanned!\n**Reason** - `{reason}`")
|
|
||||||
try:
|
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'unbanned', await interaction.original_response())
|
|
||||||
await target.send(embed=embed)
|
|
||||||
except discord.errors.HTTPException:
|
|
||||||
pass
|
|
||||||
await self.mysql_log(interaction.guild.id, interaction.user.id, 'UNBAN', target.id, 'NULL', reason)
|
|
||||||
|
|
||||||
@commands.group(autohelp=True)
|
@commands.group(autohelp=True)
|
||||||
@checks.admin()
|
@checks.admin()
|
||||||
async def moderationset(self, ctx: commands.Context):
|
async def moderationset(self, ctx: commands.Context):
|
||||||
|
|
Loading…
Reference in a new issue