Implement slash command synchronization features in environment files and update command definitions to hybrid commands across various cogs. Enhance command registration for improved user experience and streamline command handling in the bot.

This commit is contained in:
TheOnlyMace
2026-07-21 22:41:41 +02:00
parent f15c869993
commit fc77f0a3c2
51 changed files with 382 additions and 153 deletions

View File

@@ -160,7 +160,7 @@ class Owner(commands.Cog):
async with db.execute('SELECT id FROM staff') as cursor:
self.staff = {row[0] for row in await cursor.fetchall()}
@commands.command(name="staff_add", aliases=["staffadd", "addstaff"], help="Adds a user to the staff list.")
@commands.hybrid_command(name="staff_add", aliases=["staffadd", "addstaff"], help="Adds a user to the staff list.")
@commands.is_owner()
async def staff_add(self, ctx, user: discord.User):
if user.id in self.staff:
@@ -174,7 +174,7 @@ class Owner(commands.Cog):
sonu2 = discord.Embed(title=f"{TICK} Success", description=f"Added {user} to the staff list.", color=0xFF0000)
await ctx.reply(embed=sonu2, mention_author=False)
@commands.command(name="staff_remove", aliases=["staffremove", "removestaff"], help="Removes a user from the staff list.")
@commands.hybrid_command(name="staff_remove", aliases=["staffremove", "removestaff"], help="Removes a user from the staff list.")
@commands.is_owner()
async def staff_remove(self, ctx, user: discord.User):
if user.id not in self.staff:
@@ -188,7 +188,7 @@ class Owner(commands.Cog):
sonu2 = discord.Embed(title=f"{TICK} Success", description=f"Removed {user} from the staff list.", color=0xFF0000)
await ctx.reply(embed=sonu2, mention_author=False)
@commands.command(name="staff_list", aliases=["stafflist", "liststaff", "staffs"], help="Lists all staff members.")
@commands.hybrid_command(name="staff_list", aliases=["stafflist", "liststaff", "staffs"], help="Lists all staff members.")
@commands.is_owner()
async def staff_list(self, ctx):
if not self.staff:
@@ -202,7 +202,7 @@ class Owner(commands.Cog):
sonu = discord.Embed(title=f"{TICK} {BotName} Staffs", description=f"\n{staff_display}", color=0xFF0000)
await ctx.send(embed=sonu)
@commands.command(name="slist")
@commands.hybrid_command(name="slist")
@commands.check(is_owner_or_staff)
async def _slist(self, ctx):
servers = sorted(self.client.guilds, key=lambda g: g.member_count, reverse=True)
@@ -220,7 +220,7 @@ class Owner(commands.Cog):
await paginator.paginate()
@commands.command(name="mutuals", aliases=["mutual"])
@commands.hybrid_command(name="mutuals", aliases=["mutual"])
@commands.is_owner()
async def mutuals(self, ctx, user: discord.User):
guilds = [guild for guild in self.client.guilds if user in guild.members]
@@ -237,7 +237,7 @@ class Owner(commands.Cog):
ctx=ctx)
await paginator.paginate()
@commands.command(name="getinvite", aliases=["gi", "guildinvite"])
@commands.hybrid_command(name="getinvite", aliases=["gi", "guildinvite"])
@commands.is_owner()
async def getinvite(self, ctx: Context, guild= discord.Guild):
if not guild:
@@ -272,13 +272,13 @@ class Owner(commands.Cog):
await ctx.send("Forbidden.")
@commands.command(name="reload", help="Restarts the client.")
@commands.hybrid_command(name="reload", help="Restarts the client.")
@commands.is_owner()
async def _restart(self, ctx: Context):
await ctx.reply(f"{TICK} | **Successfully Restarting {BotName} It Takes 10 seconds**")
restart_program()
@commands.command(name="sync", help="Syncs all database.")
@commands.hybrid_command(name="sync", help="Syncs all database.")
@commands.is_owner()
async def _sync(self, ctx):
await ctx.reply("Syncing...", mention_author=False)
@@ -300,8 +300,35 @@ class Owner(commands.Cog):
with open('config.json', 'w') as f:
json.dump(data, f, indent=4)
@commands.hybrid_command(name="syncslash", help="Re-register all slash (/) commands with Discord.")
@commands.is_owner()
async def syncslash(self, ctx, scope: str = "all"):
"""Force-sync slash commands. scope: all | global | guild"""
if ctx.interaction:
await ctx.defer(ephemeral=True)
from utils.slash_sync import sync_slash_commands
@commands.command(name="owners")
scope = (scope or "all").lower().strip()
if scope == "global":
result = await sync_slash_commands(self.client, guilds=[], global_sync=True)
elif scope == "guild":
if not ctx.guild:
return await ctx.send("Use this in a server, or pass scope `all` / `global`.")
result = await sync_slash_commands(
self.client, guilds=[ctx.guild], global_sync=False
)
else:
result = await sync_slash_commands(self.client)
guild_n = len(result.get("guilds") or {})
err_n = len(result.get("errors") or [])
await ctx.send(
f"{TICK} Slash sync done — tree `{result.get('local_tree')}`, "
f"global `{result.get('global')}`, guilds `{guild_n}`, errors `{err_n}`."
)
@commands.hybrid_command(name="owners")
@commands.is_owner()
async def own_list(self, ctx):
nplist = OWNER_IDS
@@ -324,7 +351,7 @@ class Owner(commands.Cog):
@commands.command()
@commands.hybrid_command()
@commands.is_owner()
async def dm(self, ctx, user: discord.User, *, message: str):
""" DM the user of your choice """
@@ -336,7 +363,7 @@ class Owner(commands.Cog):
@commands.group()
@commands.hybrid_group()
@commands.is_owner()
async def change(self, ctx):
if ctx.invoked_subcommand is None:
@@ -357,7 +384,7 @@ class Owner(commands.Cog):
await ctx.send(err)
@commands.command(name="ownerban", aliases=["forceban", "dna"])
@commands.hybrid_command(name="ownerban", aliases=["forceban", "dna"])
@commands.is_owner()
async def _ownerban(self, ctx: Context, user_id: int, *, reason: str = "No reason provided"):
@@ -391,7 +418,7 @@ class Owner(commands.Cog):
await ctx.reply("User not found in this guild.", mention_author=False, delete_after=3)
await ctx.message.delete()
@commands.command(name="ownerunban", aliases=["forceunban"])
@commands.hybrid_command(name="ownerunban", aliases=["forceunban"])
@commands.is_owner()
async def _ownerunban(self, ctx: Context, user_id: int, *, reason: str = "No reason provided"):
user = self.client.get_user(user_id)
@@ -423,7 +450,7 @@ class Owner(commands.Cog):
@commands.command(name="globalunban")
@commands.hybrid_command(name="globalunban")
@commands.is_owner()
async def globalunban(self, ctx: Context, user: discord.User):
success_guilds = []
@@ -447,7 +474,7 @@ class Owner(commands.Cog):
await ctx.reply(f"{success_message}\n{error_message}", mention_author=False)
@commands.command(name="guildban")
@commands.hybrid_command(name="guildban")
@commands.is_owner()
async def guildban(self, ctx: Context, guild_id: int, user_id: int, *, reason: str = "No reason provided"):
guild = self.client.get_guild(guild_id)
@@ -467,7 +494,7 @@ class Owner(commands.Cog):
else:
await ctx.reply(f"User not found in the specified guild {guild.name}.", mention_author=False)
@commands.command(name="guildunban")
@commands.hybrid_command(name="guildunban")
@commands.is_owner()
async def guildunban(self, ctx: Context, guild_id: int, user_id: int, *, reason: str = "No reason provided"):
guild = self.client.get_guild(guild_id)
@@ -492,7 +519,7 @@ class Owner(commands.Cog):
await ctx.reply(f"An error occurred while unbanning user ID {user_id} in {guild.name}: {str(e)}", mention_author=False)
@commands.command(name="leaveguild", aliases=["leavesv"])
@commands.hybrid_command(name="leaveguild", aliases=["leavesv"])
@commands.is_owner()
async def leave_guild(self, ctx, guild_id: int):
guild = self.client.get_guild(guild_id)
@@ -503,7 +530,7 @@ class Owner(commands.Cog):
await guild.leave()
await ctx.send(f"Left the guild: {guild.name} ({guild.id})")
@commands.command(name="guildinfo")
@commands.hybrid_command(name="guildinfo")
@commands.check(is_owner_or_staff)
async def guild_info(self, ctx, guild_id: int):
guild = self.client.get_guild(guild_id)
@@ -527,7 +554,7 @@ class Owner(commands.Cog):
await ctx.send(embed=embed)
@commands.command()
@commands.hybrid_command()
@commands.is_owner()
async def servertour(self, ctx, time_in_seconds: int, member: discord.Member):
guild = ctx.guild
@@ -594,7 +621,7 @@ class Owner(commands.Cog):
@commands.group()
@commands.hybrid_group()
@commands.check(is_owner_or_staff)
@blacklist_check()
@ignore_check()
@@ -657,7 +684,7 @@ class Owner(commands.Cog):
await ctx.send(embed=embed)
@commands.command(name="forcepurgebots",
@commands.hybrid_command(name="forcepurgebots",
aliases=["fpb"],
help="Clear recently bot messages in channel (Bot owner only)")
@commands.cooldown(1, 3, commands.BucketType.user)
@@ -673,7 +700,7 @@ class Owner(commands.Cog):
await do_removal(ctx, search, predicate)
@commands.command(name="forcepurgeuser",
@commands.hybrid_command(name="forcepurgeuser",
aliases=["fpu"],
help="Clear recent messages of a user in channel (Bot owner only)")
@commands.cooldown(1, 3, commands.BucketType.user)