mirror of
https://github.com/RGBCube/minearchy-bot
synced 2025-07-27 08:57:46 +00:00
add quick timeout command, since will add a minearchy cog to clutter
This commit is contained in:
parent
621daea2ff
commit
ed730b1472
3 changed files with 52 additions and 2 deletions
|
@ -14,7 +14,7 @@ if TYPE_CHECKING:
|
||||||
class MinecraftServer(
|
class MinecraftServer(
|
||||||
commands.Cog,
|
commands.Cog,
|
||||||
name="Minecraft Server",
|
name="Minecraft Server",
|
||||||
description="Utilites for the Minecraft server.",
|
description="Utilities for the Minecraft server.",
|
||||||
):
|
):
|
||||||
def __init__(self, bot: MinearchyBot) -> None:
|
def __init__(self, bot: MinearchyBot) -> None:
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
46
cogs/moderation.py
Normal file
46
cogs/moderation.py
Normal 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))
|
|
@ -9,7 +9,11 @@ if TYPE_CHECKING:
|
||||||
from bot import MinearchyBot
|
from bot import MinearchyBot
|
||||||
|
|
||||||
|
|
||||||
class Suggestions(commands.Cog):
|
class Suggestions(
|
||||||
|
commands.Cog,
|
||||||
|
name="Suggestions",
|
||||||
|
description="Suggest stuff.",
|
||||||
|
):
|
||||||
def __init__(self, bot: MinearchyBot) -> None:
|
def __init__(self, bot: MinearchyBot) -> None:
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue