1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:03:12 +00:00

Refactor moderation module

This commit is contained in:
wlinator 2024-08-14 03:08:09 -04:00
parent 070e669959
commit 1baa0fa6c8

View file

@ -1,8 +1,8 @@
import discord
from discord.ext.commands import guild_only
from discord.ext import bridge, commands
from discord.ext.commands import guild_only
from modules.moderation import ban, cases, warn, timeout, kick, softban
from modules.moderation import ban, cases, kick, softban, timeout, warn
class Moderation(commands.Cog):
@ -28,25 +28,6 @@ class Moderation(commands.Cog):
):
await ban.ban_user(self, ctx, target, reason)
@bridge.bridge_command(
name="unban",
aliases=["ub", "pardon"],
description="Unbans a user from the server.",
help="Unbans a user from the server, you can use ID or provide their username.",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@guild_only()
async def unban_command(
self,
ctx,
target: discord.User,
*,
reason: str | None = None,
):
await ban.unban_user(ctx, target, reason)
@bridge.bridge_command(
name="case",
aliases=["c"],
@ -56,11 +37,7 @@ class Moderation(commands.Cog):
)
@bridge.has_permissions(view_audit_log=True)
@guild_only()
async def case_command(
self,
ctx,
case_number: int,
):
async def case_command(self, ctx, case_number: int):
await cases.view_case_by_number(ctx, ctx.guild.id, case_number)
@bridge.bridge_command(
@ -75,22 +52,6 @@ class Moderation(commands.Cog):
async def cases_command(self, ctx):
await cases.view_all_cases_in_guild(ctx, ctx.guild.id)
@bridge.bridge_command(
name="modcases",
aliases=["moderatorcases", "mc"],
description="View all cases by a specific moderator.",
help="Lists all moderation cases handled by a specific moderator in the current server.",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(view_audit_log=True)
@guild_only()
async def moderator_cases_command(
self,
ctx,
moderator: discord.Member,
):
await cases.view_all_cases_by_mod(ctx, ctx.guild.id, moderator)
@bridge.bridge_command(
name="editcase",
aliases=["uc", "ec"],
@ -100,32 +61,58 @@ class Moderation(commands.Cog):
)
@bridge.has_permissions(view_audit_log=True)
@guild_only()
async def edit_case_command(
self,
ctx,
case_number: int,
*,
new_reason: str,
):
async def edit_case_command(self, ctx, case_number: int, *, new_reason: str):
await cases.edit_case_reason(ctx, ctx.guild.id, case_number, new_reason)
@bridge.bridge_command(
name="warn",
aliases=["w"],
description="Warn a user.",
help="Warns a user in the server.",
name="kick",
aliases=["k"],
description="Kick a user from the server.",
help="Kicks a user from the server.",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(kick_members=True)
@commands.bot_has_permissions(kick_members=True)
@guild_only()
async def warn_command(
async def kick_command(
self,
ctx,
target: discord.Member,
*,
reason: str | None = None,
):
await warn.warn_user(ctx, target, reason)
await kick.kick_user(self, ctx, target, reason)
@bridge.bridge_command(
name="modcases",
aliases=["moderatorcases", "mc"],
description="View all cases by a specific moderator.",
help="Lists all moderation cases handled by a specific moderator in the current server.",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(view_audit_log=True)
@guild_only()
async def moderator_cases_command(self, ctx, moderator: discord.Member):
await cases.view_all_cases_by_mod(ctx, ctx.guild.id, moderator)
@bridge.bridge_command(
name="softban",
aliases=["sb"],
description="Softban a user from the server.",
help="Softbans a user from the server (ban and immediately unban to delete messages).",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@guild_only()
async def softban_command(
self,
ctx,
target: discord.Member,
*,
reason: str | None = None,
):
await softban.softban_user(ctx, target, reason)
@bridge.bridge_command(
name="timeout",
@ -147,6 +134,25 @@ class Moderation(commands.Cog):
):
await timeout.timeout_user(self, ctx, target, duration, reason)
@bridge.bridge_command(
name="unban",
aliases=["ub", "pardon"],
description="Unbans a user from the server.",
help="Unbans a user from the server, you can use ID or provide their username.",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@guild_only()
async def unban_command(
self,
ctx,
target: discord.User,
*,
reason: str | None = None,
):
await ban.unban_user(ctx, target, reason)
@bridge.bridge_command(
name="untimeout",
aliases=["removetimeout", "rto", "uto"],
@ -167,42 +173,22 @@ class Moderation(commands.Cog):
await timeout.untimeout_user(ctx, target, reason)
@bridge.bridge_command(
name="kick",
aliases=["k"],
description="Kick a user from the server.",
help="Kicks a user from the server.",
name="warn",
aliases=["w"],
description="Warn a user.",
help="Warns a user in the server.",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(kick_members=True)
@commands.bot_has_permissions(kick_members=True)
@guild_only()
async def kick_command(
async def warn_command(
self,
ctx,
target: discord.Member,
*,
reason: str | None = None,
):
await kick.kick_user(self, ctx, target, reason)
@bridge.bridge_command(
name="softban",
aliases=["sb"],
description="Softban a user from the server.",
help="Softbans a user from the server (ban and immediately unban to delete messages).",
contexts={discord.InteractionContextType.guild},
)
@bridge.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@guild_only()
async def softban_command(
self,
ctx,
target: discord.Member,
*,
reason: str | None = None,
):
await softban.softban_user(ctx, target, reason)
await warn.warn_user(ctx, target, reason)
def setup(client):