From 5d893a8a84c59fca3152c3ad95eeb6bc92ac58d1 Mon Sep 17 00:00:00 2001 From: neoarz Date: Mon, 15 Sep 2025 08:44:54 -0400 Subject: [PATCH] feat: (check description). 8ball, botinfo, context menu, feedback Moved eightball cog from general to fun category and updated help command mapping accordingly. Added support for disabling cogs via the DISABLED_COGS environment variable in bot.py. Updated embed styles and author fields for botinfo, feedback, and eightball commands. Commented out context_menus cog code. --- .env.example | 2 + bot.py | 9 +++ cogs/{general => fun}/eightball.py | 15 +--- cogs/general/botinfo.py | 20 ++--- cogs/general/context_menus.py | 124 ++++++++++++++--------------- cogs/general/feedback.py | 21 ++--- cogs/general/help.py | 4 +- 7 files changed, 87 insertions(+), 108 deletions(-) rename cogs/{general => fun}/eightball.py (83%) diff --git a/.env.example b/.env.example index 70971ae..b862cf6 100644 --- a/.env.example +++ b/.env.example @@ -2,3 +2,5 @@ TOKEN=YOUR_BOT_TOKEN_HERE PREFIX=YOUR_BOT_PREFIX_HERE INVITE_LINK=YOUR_BOT_INVITE_LINK_HERE OWNER_ID=YOUR_BOT_OWNER_ID_HERE + +DISABLED_COGS=DISABLED_COMMANDS \ No newline at end of file diff --git a/bot.py b/bot.py index 368d1b1..938f815 100644 --- a/bot.py +++ b/bot.py @@ -151,6 +151,8 @@ class DiscordBot(commands.Bot): The code in this function is executed whenever the bot will start. """ cogs_path = f"{os.path.realpath(os.path.dirname(__file__))}/cogs" + disabled_env = os.getenv("DISABLED_COGS", "") + disabled_cogs = {entry.strip().lower() for entry in disabled_env.split(",") if entry.strip()} for folder in os.listdir(cogs_path): folder_path = os.path.join(cogs_path, folder) @@ -158,6 +160,10 @@ class DiscordBot(commands.Bot): for file in os.listdir(folder_path): if file.endswith(".py") and not file.startswith('__'): extension = file[:-3] + full_name = f"{folder}.{extension}".lower() + if extension.lower() in disabled_cogs or full_name in disabled_cogs: + self.logger.info(f"Skipped disabled extension '{full_name}'") + continue try: await self.load_extension(f"cogs.{folder}.{extension}") self.logger.info(f"Loaded extension '{folder}.{extension}'") @@ -170,6 +176,9 @@ class DiscordBot(commands.Bot): for file in os.listdir(cogs_path): if file.endswith(".py") and not file.startswith('__'): extension = file[:-3] + if extension.lower() in disabled_cogs: + self.logger.info(f"Skipped disabled extension '{extension}'") + continue try: await self.load_extension(f"cogs.{extension}") self.logger.info(f"Loaded extension '{extension}'") diff --git a/cogs/general/eightball.py b/cogs/fun/eightball.py similarity index 83% rename from cogs/general/eightball.py rename to cogs/fun/eightball.py index 5d9bc3c..330ade1 100644 --- a/cogs/general/eightball.py +++ b/cogs/fun/eightball.py @@ -1,11 +1,3 @@ -""" -Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja) -Description: -🐍 A simple template to start to code your own and personalized Discord bot in Python - -Version: 6.4.0 -""" - import random import discord from discord import app_commands @@ -52,13 +44,14 @@ class EightBall(commands.Cog, name="8ball"): "Very doubtful.", ] embed = discord.Embed( - title="**My Answer:**", + title="8 Ball", description=f"{random.choice(answers)}", - color=0xBEBEFE, + color=0x7289DA, ) + embed.set_author(name="Fun", icon_url="https://yes.nighty.works/raw/eW5lLm.webp") embed.set_footer(text=f"The question was: {question}") await context.send(embed=embed) async def setup(bot) -> None: - await bot.add_cog(EightBall(bot)) + await bot.add_cog(EightBall(bot)) \ No newline at end of file diff --git a/cogs/general/botinfo.py b/cogs/general/botinfo.py index 6d81acb..d566a81 100644 --- a/cogs/general/botinfo.py +++ b/cogs/general/botinfo.py @@ -1,11 +1,3 @@ -""" -Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja) -Description: -🐍 A simple template to start to code your own and personalized Discord bot in Python - -Version: 6.4.0 -""" - import platform import discord from discord.ext import commands @@ -27,11 +19,11 @@ class BotInfo(commands.Cog, name="botinfo"): :param context: The hybrid command context. """ embed = discord.Embed( - description="Used [Krypton's](https://krypton.ninja) template", - color=0xBEBEFE, + title="Nyrix Discord Bot", + color=0x7289DA, ) - embed.set_author(name="Bot Information") - embed.add_field(name="Owner:", value="Krypton#7331", inline=True) + embed.set_author(name="Bot Information", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp") + embed.add_field(name="Owner:", value="[neoarz](https://discordapp.com/users/1015372540937502851)", inline=True) embed.add_field( name="Python Version:", value=f"{platform.python_version()}", inline=True ) @@ -40,9 +32,7 @@ class BotInfo(commands.Cog, name="botinfo"): value=f"/ (Slash Commands) or {self.bot.bot_prefix} for normal commands", inline=False, ) - embed.set_footer(text=f"Requested by {context.author}") await context.send(embed=embed) - async def setup(bot) -> None: - await bot.add_cog(BotInfo(bot)) + await bot.add_cog(BotInfo(bot)) \ No newline at end of file diff --git a/cogs/general/context_menus.py b/cogs/general/context_menus.py index c9125d0..d2b0d18 100644 --- a/cogs/general/context_menus.py +++ b/cogs/general/context_menus.py @@ -1,66 +1,58 @@ -""" -Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja) -Description: -🐍 A simple template to start to code your own and personalized Discord bot in Python - -Version: 6.4.0 -""" - -import discord -from discord import app_commands -from discord.ext import commands - - -class ContextMenus(commands.Cog, name="context_menus"): - def __init__(self, bot) -> None: - self.bot = bot - self.context_menu_user = app_commands.ContextMenu( - name="Grab ID", callback=self.grab_id - ) - self.bot.tree.add_command(self.context_menu_user) - self.context_menu_message = app_commands.ContextMenu( - name="Remove spoilers", callback=self.remove_spoilers - ) - self.bot.tree.add_command(self.context_menu_message) - - async def remove_spoilers( - self, interaction: discord.Interaction, message: discord.Message - ) -> None: - """ - Removes the spoilers from the message. This command requires the MESSAGE_CONTENT intent to work properly. - - :param interaction: The application command interaction. - :param message: The message that is being interacted with. - """ - spoiler_attachment = None - for attachment in message.attachments: - if attachment.is_spoiler(): - spoiler_attachment = attachment - break - embed = discord.Embed( - title="Message without spoilers", - description=message.content.replace("||", ""), - color=0xBEBEFE, - ) - if spoiler_attachment is not None: - embed.set_image(url=attachment.url) - await interaction.response.send_message(embed=embed, ephemeral=True) - - async def grab_id( - self, interaction: discord.Interaction, user: discord.User - ) -> None: - """ - Grabs the ID of the user. - - :param interaction: The application command interaction. - :param user: The user that is being interacted with. - """ - embed = discord.Embed( - description=f"The ID of {user.mention} is `{user.id}`.", - color=0xBEBEFE, - ) - await interaction.response.send_message(embed=embed, ephemeral=True) - - -async def setup(bot) -> None: - await bot.add_cog(ContextMenus(bot)) +# import discord +# from discord import app_commands +# from discord.ext import commands +# +# +# class ContextMenus(commands.Cog, name="context_menus"): +# def __init__(self, bot) -> None: +# self.bot = bot +# self.context_menu_user = app_commands.ContextMenu( +# name="Grab ID", callback=self.grab_id +# ) +# self.bot.tree.add_command(self.context_menu_user) +# self.context_menu_message = app_commands.ContextMenu( +# name="Remove spoilers", callback=self.remove_spoilers +# ) +# self.bot.tree.add_command(self.context_menu_message) +# +# async def remove_spoilers( +# self, interaction: discord.Interaction, message: discord.Message +# ) -> None: +# """ +# Removes the spoilers from the message. This command requires the MESSAGE_CONTENT intent to work properly. +# +# :param interaction: The application command interaction. +# :param message: The message that is being interacted with. +# """ +# spoiler_attachment = None +# for attachment in message.attachments: +# if attachment.is_spoiler(): +# spoiler_attachment = attachment +# break +# embed = discord.Embed( +# title="Message without spoilers", +# description=message.content.replace("||", ""), +# color=0xBEBEFE, +# ) +# if spoiler_attachment is not None: +# embed.set_image(url=attachment.url) +# await interaction.response.send_message(embed=embed, ephemeral=True) +# +# async def grab_id( +# self, interaction: discord.Interaction, user: discord.User +# ) -> None: +# """ +# Grabs the ID of the user. +# +# :param interaction: The application command interaction. +# :param user: The user that is being interacted with. +# """ +# embed = discord.Embed( +# description=f"The ID of {user.mention} is `{user.id}`.", +# color=0xBEBEFE, +# ) +# await interaction.response.send_message(embed=embed, ephemeral=True) +# +# +# async def setup(bot) -> None: +# await bot.add_cog(ContextMenus(bot)) diff --git a/cogs/general/feedback.py b/cogs/general/feedback.py index 8535ee2..43471f7 100644 --- a/cogs/general/feedback.py +++ b/cogs/general/feedback.py @@ -1,11 +1,3 @@ -""" -Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja) -Description: -🐍 A simple template to start to code your own and personalized Discord bot in Python - -Version: 6.4.0 -""" - import discord from discord import app_commands from discord.ext import commands @@ -46,9 +38,10 @@ class Feedback(commands.Cog, name="feedback"): interaction = feedback_form.interaction await interaction.response.send_message( embed=discord.Embed( - description="Thank you for your feedback, the owners have been notified about it.", - color=0xBEBEFE, - ) + title="Thank You!", + description="Your feedback has been submitted, the owners have been notified about it.", + color=0x7289DA, + ).set_author(name="Feedback System", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp") ) app_owner = (await self.bot.application_info()).owner @@ -56,10 +49,10 @@ class Feedback(commands.Cog, name="feedback"): embed=discord.Embed( title="New Feedback", description=f"{interaction.user} (<@{interaction.user.id}>) has submitted a new feedback:\n```\n{feedback_form.answer}\n```", - color=0xBEBEFE, - ) + color=0x7289DA, + ).set_author(name="Feedback System", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp") ) async def setup(bot) -> None: - await bot.add_cog(Feedback(bot)) + await bot.add_cog(Feedback(bot)) \ No newline at end of file diff --git a/cogs/general/help.py b/cogs/general/help.py index 74270d3..a470b09 100644 --- a/cogs/general/help.py +++ b/cogs/general/help.py @@ -44,13 +44,13 @@ class Help(commands.Cog, name="help"): "ping": "general", "invite": "general", "server": "general", - "8ball": "general", "feedback": "general", - "context_menus": "general", + # "context_menus": "general", "randomfact": "fun", "coinflip": "fun", "rps": "fun", + "8ball": "fun", "kick": "moderation", "ban": "moderation",