diff --git a/cogs/mc_server.py b/cogs/mc_server.py index ddfd85b..f8b43ca 100644 --- a/cogs/mc_server.py +++ b/cogs/mc_server.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: class MinecraftServer( commands.Cog, name="Minecraft Server", - description="Utilites for the Minecraft server.", + description="Utilities for the Minecraft server.", ): def __init__(self, bot: MinearchyBot) -> None: self.bot = bot diff --git a/cogs/moderation.py b/cogs/moderation.py new file mode 100644 index 0000000..7ba16fa --- /dev/null +++ b/cogs/moderation.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + +import discord +from discord.ext import commands +from datetime import timedelta +from typing import Optional + +if TYPE_CHECKING: + from bot import MinearchyBot + + +class Moderation(commands.Cog): + def __init__(self, bot: MinearchyBot) -> None: + self.bot = bot + + @commands.command( + aliases=["mute"], + brief="Times out a user.", + help="Times out a user." + ) + @commands.has_permissions(manage_messages=True) + async def timeout(self, ctx: commands.Context, member: discord.Member, duration: Optional[str]) -> None: + times = { + "d": "days", + "h": "hours", + "m": "minutes", + "s": "seconds", + } + if duration is None: + duration = "1d" + if duration[-1] not in times or len(duration) < 2: + await ctx.reply("Invalid duration. Valid durations are: d, h, m, s.") + return + try: + time = int(duration[:-1]) + except ValueError: + await ctx.reply("Invalid time.") + return + + await member.timeout(timedelta(**{times[duration[-1]]: time}), reason=f"Timed out by moderator {ctx.author}") + + +async def setup(bot: MinearchyBot) -> None: + await bot.add_cog(Moderation(bot)) diff --git a/cogs/suggestions.py b/cogs/suggestions.py index 2c1bac8..33f1e66 100644 --- a/cogs/suggestions.py +++ b/cogs/suggestions.py @@ -9,7 +9,11 @@ if TYPE_CHECKING: from bot import MinearchyBot -class Suggestions(commands.Cog): +class Suggestions( + commands.Cog, + name="Suggestions", + description="Suggest stuff.", +): def __init__(self, bot: MinearchyBot) -> None: self.bot = bot