Refactor command definitions across various cogs to replace hybrid commands with regular commands for improved consistency and clarity. Update command structures in moderation, music, and other cogs to enhance user experience and streamline command handling.
This commit is contained in:
@@ -25,7 +25,7 @@ class Ban(commands.Cog):
|
||||
def get_user_avatar(self, user):
|
||||
return user.avatar.url if user.avatar else user.default_avatar.url
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="ban",
|
||||
help="Bans a user from the Server",
|
||||
usage="ban <member>",
|
||||
|
||||
@@ -20,7 +20,7 @@ class Hide(commands.Cog):
|
||||
self.bot = bot
|
||||
self.color = discord.Color.from_rgb(255, 0, 0) # Red color for embeds
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="hide",
|
||||
help="Hides a channel from the default role (@everyone).",
|
||||
usage="hide [channel]",
|
||||
|
||||
@@ -22,7 +22,7 @@ class Kick(commands.Cog):
|
||||
# Color is set to Red (255, 0, 0) as requested
|
||||
self.color = discord.Color.from_rgb(255, 0, 0)
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="kick",
|
||||
help="Kicks a member from the server.",
|
||||
usage="kick <member> [reason]",
|
||||
|
||||
@@ -20,7 +20,7 @@ class Lock(commands.Cog):
|
||||
self.bot = bot
|
||||
self.color = discord.Color.red()
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="lock",
|
||||
description="Locks a channel to prevent sending messages.",
|
||||
aliases=["lockchannel"]
|
||||
|
||||
224
bot/cogs/moderation/mod_hub.py
Normal file
224
bot/cogs/moderation/mod_hub.py
Normal file
@@ -0,0 +1,224 @@
|
||||
# ╔══════════════════════════════════════════════════════════════════╗
|
||||
# ║ ║
|
||||
# ║ +-+-+-+-+-+-+-+-+ ║
|
||||
# ║ |H|e|x|a|H|o|s|t| ║
|
||||
# ║ +-+-+-+-+-+-+-+-+ ║
|
||||
# ║ ║
|
||||
# ║ © 2026 HexaHost — All Rights Reserved ║
|
||||
# ║ ║
|
||||
# ║ discord ── https://discord.gg/hexahost ║
|
||||
# ║ github ── https://github.com/theoneandonlymace ║
|
||||
# ║ ║
|
||||
# ╚══════════════════════════════════════════════════════════════════╝
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
class ModHub(commands.Cog):
|
||||
"""Slash/prefix hub that exposes moderation actions under `/mod <subcommand>`."""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
async def _get_cog(self, ctx: commands.Context, name: str):
|
||||
cog = self.bot.get_cog(name)
|
||||
if not cog:
|
||||
await ctx.send(f"{name} module unavailable.")
|
||||
return None
|
||||
return cog
|
||||
|
||||
@commands.hybrid_group(
|
||||
name="mod",
|
||||
description="Moderation commands",
|
||||
fallback="help",
|
||||
invoke_without_command=True,
|
||||
)
|
||||
@commands.guild_only()
|
||||
async def mod(self, ctx: commands.Context):
|
||||
"""Moderation root — use `/mod <subcommand>` or `>mod <subcommand>`."""
|
||||
if ctx.subcommand_passed is None:
|
||||
await ctx.send_help(ctx.command)
|
||||
|
||||
@mod.command(name="ban", description="Ban a user")
|
||||
@commands.has_permissions(ban_members=True)
|
||||
@commands.bot_has_permissions(ban_members=True)
|
||||
@commands.guild_only()
|
||||
async def mod_ban(self, ctx: commands.Context, user: discord.User, *, reason: str = None):
|
||||
cog = await self._get_cog(ctx, "Ban")
|
||||
if not cog:
|
||||
return
|
||||
await cog.ban(ctx, user, reason=reason)
|
||||
|
||||
@mod.command(name="unban", description="Unban a user")
|
||||
@commands.has_permissions(ban_members=True)
|
||||
@commands.bot_has_permissions(ban_members=True)
|
||||
@commands.guild_only()
|
||||
async def mod_unban(self, ctx: commands.Context, user: discord.User, *, reason: str = None):
|
||||
cog = await self._get_cog(ctx, "Unban")
|
||||
if not cog:
|
||||
return
|
||||
await cog.unban(ctx, user, reason=reason)
|
||||
|
||||
@mod.command(name="kick", description="Kick a member")
|
||||
@commands.has_permissions(kick_members=True)
|
||||
@commands.bot_has_permissions(kick_members=True)
|
||||
@commands.guild_only()
|
||||
async def mod_kick(self, ctx: commands.Context, member: discord.Member, *, reason: str = None):
|
||||
cog = await self._get_cog(ctx, "Kick")
|
||||
if not cog:
|
||||
return
|
||||
await cog.kick_command(ctx, member, reason=reason)
|
||||
|
||||
@mod.command(name="mute", description="Mute / timeout a member")
|
||||
@commands.has_permissions(moderate_members=True)
|
||||
@commands.bot_has_permissions(moderate_members=True)
|
||||
@commands.guild_only()
|
||||
async def mod_mute(
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
user: discord.Member,
|
||||
time: str = None,
|
||||
*,
|
||||
reason: str = None,
|
||||
):
|
||||
cog = await self._get_cog(ctx, "Mute")
|
||||
if not cog:
|
||||
return
|
||||
await cog.mute(ctx, user, time, reason=reason)
|
||||
|
||||
@mod.command(name="unmute", description="Remove a timeout from a member")
|
||||
@commands.has_permissions(moderate_members=True)
|
||||
@commands.bot_has_permissions(moderate_members=True)
|
||||
@commands.guild_only()
|
||||
async def mod_unmute(self, ctx: commands.Context, user: discord.Member):
|
||||
cog = await self._get_cog(ctx, "Unmute")
|
||||
if not cog:
|
||||
return
|
||||
await cog.unmute(ctx, user)
|
||||
|
||||
@mod.command(name="warn", description="Warn a member")
|
||||
@commands.has_permissions(moderate_members=True)
|
||||
@commands.guild_only()
|
||||
async def mod_warn(self, ctx: commands.Context, user: discord.Member, *, reason: str = None):
|
||||
cog = await self._get_cog(ctx, "Warn")
|
||||
if not cog:
|
||||
return
|
||||
await cog.warn(ctx, user, reason=reason)
|
||||
|
||||
@mod.command(name="clearwarns", description="Clear warnings for a member")
|
||||
@commands.has_permissions(moderate_members=True)
|
||||
@commands.guild_only()
|
||||
async def mod_clearwarns(self, ctx: commands.Context, user: discord.Member):
|
||||
cog = await self._get_cog(ctx, "Warn")
|
||||
if not cog:
|
||||
return
|
||||
await cog.clearwarns(ctx, user)
|
||||
|
||||
@mod.command(name="lock", description="Lock a channel")
|
||||
@commands.has_permissions(manage_channels=True)
|
||||
@commands.bot_has_permissions(manage_channels=True)
|
||||
@commands.guild_only()
|
||||
async def mod_lock(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||
cog = await self._get_cog(ctx, "Lock")
|
||||
if not cog:
|
||||
return
|
||||
await cog.lock_command(ctx, channel)
|
||||
|
||||
@mod.command(name="unlock", description="Unlock a channel")
|
||||
@commands.has_permissions(manage_roles=True)
|
||||
@commands.bot_has_permissions(manage_roles=True)
|
||||
@commands.guild_only()
|
||||
async def mod_unlock(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||
cog = await self._get_cog(ctx, "Unlock")
|
||||
if not cog:
|
||||
return
|
||||
await cog.unlock_command(ctx, channel)
|
||||
|
||||
@mod.command(name="hide", description="Hide a channel")
|
||||
@commands.has_permissions(manage_channels=True)
|
||||
@commands.bot_has_permissions(manage_channels=True)
|
||||
@commands.guild_only()
|
||||
async def mod_hide(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||
cog = await self._get_cog(ctx, "Hide")
|
||||
if not cog:
|
||||
return
|
||||
await cog.hide_command(ctx, channel)
|
||||
|
||||
@mod.command(name="unhide", description="Unhide a channel")
|
||||
@commands.has_permissions(manage_channels=True)
|
||||
@commands.bot_has_permissions(manage_channels=True)
|
||||
@commands.guild_only()
|
||||
async def mod_unhide(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||
cog = await self._get_cog(ctx, "Unhide")
|
||||
if not cog:
|
||||
return
|
||||
await cog.unhide_command(ctx, channel)
|
||||
|
||||
@mod.command(name="lockall", description="Lock all channels")
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.guild_only()
|
||||
async def mod_lockall(self, ctx: commands.Context):
|
||||
cog = await self._get_cog(ctx, "Moderation")
|
||||
if not cog:
|
||||
return
|
||||
await cog.lockall(ctx)
|
||||
|
||||
@mod.command(name="unlockall", description="Unlock all channels")
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.guild_only()
|
||||
async def mod_unlockall(self, ctx: commands.Context):
|
||||
cog = await self._get_cog(ctx, "Moderation")
|
||||
if not cog:
|
||||
return
|
||||
await cog.unlockall(ctx)
|
||||
|
||||
@mod.command(name="nuke", description="Nuke the current channel")
|
||||
@commands.has_permissions(manage_channels=True)
|
||||
@commands.guild_only()
|
||||
async def mod_nuke(self, ctx: commands.Context):
|
||||
cog = await self._get_cog(ctx, "Moderation")
|
||||
if not cog:
|
||||
return
|
||||
await cog._nuke(ctx)
|
||||
|
||||
@mod.command(name="slowmode", description="Set channel slowmode")
|
||||
@commands.has_permissions(manage_messages=True)
|
||||
@commands.guild_only()
|
||||
async def mod_slowmode(self, ctx: commands.Context, seconds: int = 0):
|
||||
cog = await self._get_cog(ctx, "Moderation")
|
||||
if not cog:
|
||||
return
|
||||
await cog._slowmode(ctx, seconds)
|
||||
|
||||
@mod.command(name="nick", description="Change a member's nickname")
|
||||
@commands.has_permissions(manage_nicknames=True)
|
||||
@commands.bot_has_permissions(manage_nicknames=True)
|
||||
@commands.guild_only()
|
||||
async def mod_nick(
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
member: discord.Member,
|
||||
*,
|
||||
name: str = None,
|
||||
):
|
||||
cog = await self._get_cog(ctx, "Moderation")
|
||||
if not cog:
|
||||
return
|
||||
await cog.changenickname(ctx, member, name=name)
|
||||
|
||||
@mod.command(name="audit", description="View recent audit log entries")
|
||||
@commands.has_permissions(view_audit_log=True)
|
||||
@commands.bot_has_permissions(view_audit_log=True)
|
||||
@commands.guild_only()
|
||||
async def mod_audit(self, ctx: commands.Context, limit: int):
|
||||
cog = await self._get_cog(ctx, "Moderation")
|
||||
if not cog:
|
||||
return
|
||||
await cog.auditlog(ctx, limit)
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ModHub(bot))
|
||||
@@ -126,7 +126,7 @@ class Moderation(commands.Cog):
|
||||
|
||||
|
||||
|
||||
@commands.hybrid_command(name="unlockall",
|
||||
@commands.command(name="unlockall",
|
||||
help="Unlocks all channels in the Guild.",
|
||||
usage="unlockall")
|
||||
@blacklist_check()
|
||||
@@ -211,7 +211,7 @@ class Moderation(commands.Cog):
|
||||
|
||||
|
||||
|
||||
@commands.hybrid_command(name="lockall",
|
||||
@commands.command(name="lockall",
|
||||
help="locks all the channels in Guild.",
|
||||
usage="lockall")
|
||||
@blacklist_check()
|
||||
@@ -294,7 +294,7 @@ class Moderation(commands.Cog):
|
||||
await ctx.send(embed=denied, mention_author=False)
|
||||
|
||||
|
||||
@commands.hybrid_command(name="give",
|
||||
@commands.command(name="give",
|
||||
help="Gives the mentioned user a role.",
|
||||
usage="give <user> <role>",
|
||||
aliases=["addrole"])
|
||||
@@ -364,7 +364,7 @@ class Moderation(commands.Cog):
|
||||
|
||||
|
||||
|
||||
@commands.hybrid_command(name="hideall", help="Hides all the channels .",
|
||||
@commands.command(name="hideall", help="Hides all the channels .",
|
||||
usage="hideall")
|
||||
@blacklist_check()
|
||||
@ignore_check()
|
||||
@@ -442,7 +442,7 @@ class Moderation(commands.Cog):
|
||||
icon_url=ctx.author.avatar.url if ctx.author.avatar else ctx.author.default_avatar.url)
|
||||
await ctx.send(embed=denied, mention_author=False)
|
||||
|
||||
@commands.hybrid_command(name="unhideall", help="Unhides all the channels in the server.",
|
||||
@commands.command(name="unhideall", help="Unhides all the channels in the server.",
|
||||
usage="unhideall")
|
||||
@blacklist_check()
|
||||
@ignore_check()
|
||||
@@ -522,7 +522,7 @@ class Moderation(commands.Cog):
|
||||
|
||||
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="prefix",
|
||||
aliases=["setprefix", "prefixset"],
|
||||
help="Allows you to change the prefix of the bot for this server"
|
||||
@@ -560,7 +560,7 @@ class Moderation(commands.Cog):
|
||||
|
||||
|
||||
|
||||
@commands.hybrid_command(name="clone", help="Clones a channel.")
|
||||
@commands.command(name="clone", help="Clones a channel.")
|
||||
@blacklist_check()
|
||||
@ignore_check()
|
||||
@commands.has_permissions(manage_channels=True)
|
||||
@@ -604,7 +604,7 @@ class Moderation(commands.Cog):
|
||||
await ctx.send(embed=error)
|
||||
|
||||
|
||||
@commands.hybrid_command(name="nick",
|
||||
@commands.command(name="nick",
|
||||
aliases=['setnick'],
|
||||
help="To change someone's nickname.",
|
||||
usage="nick [member]")
|
||||
@@ -680,7 +680,7 @@ class Moderation(commands.Cog):
|
||||
await ctx.send(embed=error)
|
||||
|
||||
|
||||
@commands.hybrid_command(name="nuke", help="Nukes a channel", usage="nuke")
|
||||
@commands.command(name="nuke", help="Nukes a channel", usage="nuke")
|
||||
@blacklist_check()
|
||||
@ignore_check()
|
||||
@top_check()
|
||||
@@ -744,7 +744,7 @@ class Moderation(commands.Cog):
|
||||
|
||||
|
||||
|
||||
@commands.hybrid_command(name="slowmode",
|
||||
@commands.command(name="slowmode",
|
||||
help="Changes the slowmode",
|
||||
usage="slowmode [seconds]",
|
||||
aliases=["slow"])
|
||||
@@ -774,7 +774,7 @@ class Moderation(commands.Cog):
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
@commands.hybrid_command(name="unslowmode",
|
||||
@commands.command(name="unslowmode",
|
||||
help="Disables slowmode",
|
||||
usage="unslowmode",
|
||||
aliases=["unslow"])
|
||||
@@ -976,11 +976,10 @@ class Moderation(commands.Cog):
|
||||
|
||||
|
||||
|
||||
@commands.hybrid_command(name="unbanall",
|
||||
@commands.command(name="unbanall",
|
||||
help="Unbans Everyone In The Guild!",
|
||||
aliases=['massunban'],
|
||||
usage="Unbanall",
|
||||
with_app_command=True)
|
||||
usage="Unbanall")
|
||||
@blacklist_check()
|
||||
@ignore_check()
|
||||
@commands.cooldown(1, 30, commands.BucketType.user)
|
||||
@@ -1041,7 +1040,7 @@ class Moderation(commands.Cog):
|
||||
view.add_item(button1)
|
||||
await ctx.reply(embed=embed, view=view, mention_author=False)
|
||||
|
||||
@commands.hybrid_command(name="audit",
|
||||
@commands.command(name="audit",
|
||||
help="See recents audit log action in the server .")
|
||||
@blacklist_check()
|
||||
@ignore_check()
|
||||
|
||||
@@ -132,7 +132,7 @@ class Mute(commands.Cog):
|
||||
return timedelta(days=time_value), f"{time_value} days"
|
||||
return None, None
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="mute",
|
||||
help="Mutes a user with optional time and reason",
|
||||
usage="mute <member> [time] [reason]",
|
||||
|
||||
@@ -132,7 +132,7 @@ class Unban(commands.Cog):
|
||||
def get_user_avatar(self, user):
|
||||
return user.avatar.url if user.avatar else user.default_avatar.url
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="unban",
|
||||
help="Unbans a user from the Server",
|
||||
usage="unban <member>",
|
||||
|
||||
@@ -20,7 +20,7 @@ class Unhide(commands.Cog):
|
||||
self.bot = bot
|
||||
self.color = discord.Color.from_rgb(255,0, 0) # Green color for success
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="unhide",
|
||||
help="Unhides a channel for the default role (@everyone).",
|
||||
usage="unhide [channel]",
|
||||
|
||||
@@ -69,7 +69,7 @@ class Unlock(commands.Cog):
|
||||
self.bot = bot
|
||||
self.color = discord.Color.from_rgb(255, 0, 0)
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="unlock",
|
||||
help="Unlocks a channel to allow sending messages.",
|
||||
usage="unlock <channel>",
|
||||
|
||||
@@ -140,7 +140,7 @@ class Unmute(commands.Cog):
|
||||
def get_user_avatar(self, user):
|
||||
return user.avatar.url if user.avatar else user.default_avatar.url
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="unmute",
|
||||
help="Unmutes a user from the Server",
|
||||
usage="unmute <member>",
|
||||
|
||||
@@ -94,7 +94,7 @@ class Warn(commands.Cog):
|
||||
except Exception as e:
|
||||
print(f"Error during database setup: {e}")
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="warn",
|
||||
help="Warn a user in the server",
|
||||
usage="warn <user> [reason]",
|
||||
@@ -156,7 +156,7 @@ class Warn(commands.Cog):
|
||||
await ctx.send(f"An error occurred: {str(e)}")
|
||||
print(f"Error during warn command: {e}")
|
||||
|
||||
@commands.hybrid_command(
|
||||
@commands.command(
|
||||
name="clearwarns",
|
||||
help="Clear all warnings for a user",
|
||||
aliases=["clearwarn" , "clearwarnings"],
|
||||
|
||||
Reference in New Issue
Block a user