mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
refactor: (description) owner command handling && fix colors
Standardized embed colors to Discord blurple (0x7289DA) across all cogs. Refactored owner command modules (say, shutdown, sync) to use a shared send_embed helper and improved error handling for permission checks. Updated botinfo title and improved bot owner/team logging in bot.py. Help command now always lists 'owner' category, removing permission checks from category display.
This commit is contained in:
@@ -42,7 +42,7 @@ class CogManagement(commands.Cog, name="cog_management"):
|
||||
await self.send_embed(context, embed, ephemeral=True)
|
||||
return
|
||||
embed = discord.Embed(
|
||||
description=f"Successfully loaded the `{cog}` cog.", color=0xBEBEFE
|
||||
description=f"Successfully loaded the `{cog}` cog.", color=0x7289DA
|
||||
)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
@@ -71,7 +71,7 @@ class CogManagement(commands.Cog, name="cog_management"):
|
||||
await self.send_embed(context, embed, ephemeral=True)
|
||||
return
|
||||
embed = discord.Embed(
|
||||
description=f"Successfully unloaded the `{cog}` cog.", color=0xBEBEFE
|
||||
description=f"Successfully unloaded the `{cog}` cog.", color=0x7289DA
|
||||
)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
@@ -101,7 +101,7 @@ class CogManagement(commands.Cog, name="cog_management"):
|
||||
return
|
||||
embed = discord.Embed(
|
||||
title="Cog Management",
|
||||
description=f"Successfully reloaded the `{cog}` cog.", color=0xBEBEFE
|
||||
description=f"Successfully reloaded the `{cog}` cog.", color=0x7289DA
|
||||
)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
|
||||
@@ -8,6 +8,16 @@ class Say(commands.Cog, name="say"):
|
||||
def __init__(self, bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
async def send_embed(self, context: Context, embed: discord.Embed, *, ephemeral: bool = False) -> None:
|
||||
interaction = getattr(context, "interaction", None)
|
||||
if interaction is not None:
|
||||
if interaction.response.is_done():
|
||||
await interaction.followup.send(embed=embed, ephemeral=ephemeral)
|
||||
else:
|
||||
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
@commands.hybrid_command(
|
||||
name="say",
|
||||
description="The bot will say anything you want.",
|
||||
@@ -36,8 +46,26 @@ class Say(commands.Cog, name="say"):
|
||||
:param context: The hybrid command context.
|
||||
:param message: The message that should be repeated by the bot.
|
||||
"""
|
||||
embed = discord.Embed(description=message, color=0xBEBEFE)
|
||||
await context.send(embed=embed)
|
||||
embed = discord.Embed(
|
||||
title="Say",
|
||||
description=message,
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
|
||||
|
||||
async def cog_command_error(self, context: Context, error) -> None:
|
||||
if isinstance(error, commands.NotOwner):
|
||||
embed = discord.Embed(
|
||||
title="Permission Denied",
|
||||
description="You are not the owner of this bot!",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed, ephemeral=True)
|
||||
else:
|
||||
raise error
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
|
||||
@@ -6,6 +6,16 @@ from discord.ext.commands import Context
|
||||
class Shutdown(commands.Cog, name="shutdown"):
|
||||
def __init__(self, bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
async def send_embed(self, context: Context, embed: discord.Embed, *, ephemeral: bool = False) -> None:
|
||||
interaction = getattr(context, "interaction", None)
|
||||
if interaction is not None:
|
||||
if interaction.response.is_done():
|
||||
await interaction.followup.send(embed=embed, ephemeral=ephemeral)
|
||||
else:
|
||||
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
@commands.hybrid_command(
|
||||
name="shutdown",
|
||||
@@ -18,10 +28,27 @@ class Shutdown(commands.Cog, name="shutdown"):
|
||||
|
||||
:param context: The hybrid command context.
|
||||
"""
|
||||
embed = discord.Embed(description="Shutting down. Bye! :wave:", color=0xBEBEFE)
|
||||
await context.send(embed=embed)
|
||||
embed = discord.Embed(
|
||||
title="Shutdown",
|
||||
description="Shutting down. Bye! <a:PandaThanos:1417483671253811262>",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
|
||||
await self.send_embed(context, embed)
|
||||
await self.bot.close()
|
||||
|
||||
async def cog_command_error(self, context: Context, error) -> None:
|
||||
if isinstance(error, commands.NotOwner):
|
||||
embed = discord.Embed(
|
||||
title="Permission Denied",
|
||||
description="You are not the owner of this bot!",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed, ephemeral=True)
|
||||
else:
|
||||
raise error
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
await bot.add_cog(Shutdown(bot))
|
||||
|
||||
@@ -8,6 +8,16 @@ class Sync(commands.Cog, name="sync"):
|
||||
def __init__(self, bot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
async def send_embed(self, context: Context, embed: discord.Embed, *, ephemeral: bool = False) -> None:
|
||||
interaction = getattr(context, "interaction", None)
|
||||
if interaction is not None:
|
||||
if interaction.response.is_done():
|
||||
await interaction.followup.send(embed=embed, ephemeral=ephemeral)
|
||||
else:
|
||||
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
@commands.command(
|
||||
name="sync",
|
||||
description="Synchonizes the slash commands.",
|
||||
@@ -24,24 +34,31 @@ class Sync(commands.Cog, name="sync"):
|
||||
if scope == "global":
|
||||
await context.bot.tree.sync()
|
||||
embed = discord.Embed(
|
||||
title="Sync",
|
||||
description="Slash commands have been globally synchronized.",
|
||||
color=0xBEBEFE,
|
||||
color=0x7289DA,
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
return
|
||||
elif scope == "guild":
|
||||
context.bot.tree.copy_global_to(guild=context.guild)
|
||||
await context.bot.tree.sync(guild=context.guild)
|
||||
embed = discord.Embed(
|
||||
title="Sync",
|
||||
description="Slash commands have been synchronized in this guild.",
|
||||
color=0xBEBEFE,
|
||||
color=0x7289DA,
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
return
|
||||
embed = discord.Embed(
|
||||
description="The scope must be `global` or `guild`.", color=0xE02B2B
|
||||
title="Error",
|
||||
description="The scope must be `global` or `guild`.",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed, ephemeral=True)
|
||||
|
||||
@commands.command(
|
||||
name="unsync",
|
||||
@@ -62,24 +79,44 @@ class Sync(commands.Cog, name="sync"):
|
||||
context.bot.tree.clear_commands(guild=None)
|
||||
await context.bot.tree.sync()
|
||||
embed = discord.Embed(
|
||||
title="Unsync",
|
||||
description="Slash commands have been globally unsynchronized.",
|
||||
color=0xBEBEFE,
|
||||
color=0x7289DA,
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
return
|
||||
elif scope == "guild":
|
||||
context.bot.tree.clear_commands(guild=context.guild)
|
||||
await context.bot.tree.sync(guild=context.guild)
|
||||
embed = discord.Embed(
|
||||
title="Unsync",
|
||||
description="Slash commands have been unsynchronized in this guild.",
|
||||
color=0xBEBEFE,
|
||||
color=0x7289DA,
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed)
|
||||
return
|
||||
embed = discord.Embed(
|
||||
description="The scope must be `global` or `guild`.", color=0xE02B2B
|
||||
title="Error",
|
||||
description="The scope must be `global` or `guild`.",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed, ephemeral=True)
|
||||
|
||||
|
||||
async def cog_command_error(self, context: Context, error) -> None:
|
||||
if isinstance(error, commands.NotOwner):
|
||||
embed = discord.Embed(
|
||||
title="Permission Denied",
|
||||
description="You are not the owner of this bot!",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
embed.set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
|
||||
await self.send_embed(context, embed, ephemeral=True)
|
||||
else:
|
||||
raise error
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
|
||||
Reference in New Issue
Block a user