feat(aurora): added a slowmode command
All checks were successful
Actions / Build Documentation (MkDocs) (pull_request) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (pull_request) Successful in 39s

This commit is contained in:
Seaswimmer 2024-05-24 03:46:20 -04:00
parent dc51aa7bdc
commit 67b33a2eb8
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F
2 changed files with 46 additions and 9 deletions

View file

@ -20,8 +20,7 @@ from redbot.core import app_commands, commands, data_manager
from redbot.core.app_commands import Choice
from redbot.core.bot import Red
from redbot.core.commands.converter import parse_relativedelta, parse_timedelta
from redbot.core.utils.chat_formatting import (box, error, humanize_list,
humanize_timedelta, warning)
from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning
from .importers.aurora import ImportAuroraView
from .importers.galacticbot import ImportGalacticBotView
@ -33,14 +32,10 @@ from .models.change import Change
from .models.moderation import Moderation
from .utilities.config import config, register_config
from .utilities.database import connect, create_guild_table
from .utilities.factory import (addrole_embed, case_factory, changes_factory,
evidenceformat_factory, guild_embed,
immune_embed, message_factory, overrides_embed)
from .utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed
from .utilities.json import dump
from .utilities.logger import logger
from .utilities.utils import (check_moddable, check_permissions,
get_footer_image, log, send_evidenceformat,
timedelta_from_relativedelta)
from .utilities.utils import check_moddable, check_permissions, get_footer_image, log, send_evidenceformat, timedelta_from_relativedelta
class Aurora(commands.Cog):
@ -970,6 +965,48 @@ class Aurora(commands.Cog):
await log(interaction, moderation.id)
await send_evidenceformat(interaction, moderation.id)
@app_commands.command(name="slowmode")
async def slowmode(
self,
interaction: discord.Interaction,
interval: int,
channel: discord.TextChannel | None = None,
reason: str | None = None,
):
"""Set the slowmode of a channel.
Parameters
-----------
interval: int
The slowmode interval in seconds
channel: discord.TextChannel
The channel to set the slowmode in
reason: str
Why are you setting the slowmode?"""
if channel is None:
channel = interaction.channel
if not await check_moddable(channel, interaction, ["manage_channels"]):
return
await channel.edit(slowmode_delay=interval)
await interaction.response.send_message(f"Slowmode in {channel.mention} has been set to {interval} seconds!\n**Reason** - `{reason}`")
moderation = Moderation.log(
interaction.client,
interaction.guild.id,
interaction.user.id,
"SLOWMODE",
"CHANNEL",
channel.id,
None,
None,
reason,
)
await interaction.edit_original_response(content=f"Slowmode in {channel.mention} has been set to {interval} seconds! (Case `#{moderation.id:,}`)\n**Reason** - `{reason}`")
await log(interaction, moderation.id)
await send_evidenceformat(interaction, moderation.id)
@app_commands.command(name="history")
async def history(
self,

View file

@ -222,7 +222,7 @@ class Moderation(AuroraGuildModel):
moderation_type: str,
target_type: str,
target_id: int,
role_id: int,
role_id: int | None = None,
duration: timedelta | None = None,
reason: str | None = None,
database: sqlite3.Connection | None = None,