mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
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.
This commit is contained in:
@@ -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
|
||||
9
bot.py
9
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}'")
|
||||
|
||||
@@ -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,10 +44,11 @@ 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)
|
||||
|
||||
@@ -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))
|
||||
@@ -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))
|
||||
|
||||
@@ -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,8 +49,8 @@ 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")
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user