1
Fork 0
mirror of https://github.com/RGBCube/minearchy-bot synced 2025-07-27 00:47:44 +00:00

add quick timeout command, since will add a minearchy cog to clutter

This commit is contained in:
RGBCube 2022-07-25 15:41:44 +03:00
parent 621daea2ff
commit ed730b1472
3 changed files with 52 additions and 2 deletions

View file

@ -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

46
cogs/moderation.py Normal file
View file

@ -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))

View file

@ -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