mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +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
|
PREFIX=YOUR_BOT_PREFIX_HERE
|
||||||
INVITE_LINK=YOUR_BOT_INVITE_LINK_HERE
|
INVITE_LINK=YOUR_BOT_INVITE_LINK_HERE
|
||||||
OWNER_ID=YOUR_BOT_OWNER_ID_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.
|
The code in this function is executed whenever the bot will start.
|
||||||
"""
|
"""
|
||||||
cogs_path = f"{os.path.realpath(os.path.dirname(__file__))}/cogs"
|
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):
|
for folder in os.listdir(cogs_path):
|
||||||
folder_path = os.path.join(cogs_path, folder)
|
folder_path = os.path.join(cogs_path, folder)
|
||||||
@@ -158,6 +160,10 @@ class DiscordBot(commands.Bot):
|
|||||||
for file in os.listdir(folder_path):
|
for file in os.listdir(folder_path):
|
||||||
if file.endswith(".py") and not file.startswith('__'):
|
if file.endswith(".py") and not file.startswith('__'):
|
||||||
extension = file[:-3]
|
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:
|
try:
|
||||||
await self.load_extension(f"cogs.{folder}.{extension}")
|
await self.load_extension(f"cogs.{folder}.{extension}")
|
||||||
self.logger.info(f"Loaded extension '{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):
|
for file in os.listdir(cogs_path):
|
||||||
if file.endswith(".py") and not file.startswith('__'):
|
if file.endswith(".py") and not file.startswith('__'):
|
||||||
extension = file[:-3]
|
extension = file[:-3]
|
||||||
|
if extension.lower() in disabled_cogs:
|
||||||
|
self.logger.info(f"Skipped disabled extension '{extension}'")
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
await self.load_extension(f"cogs.{extension}")
|
await self.load_extension(f"cogs.{extension}")
|
||||||
self.logger.info(f"Loaded extension '{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 random
|
||||||
import discord
|
import discord
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
@@ -52,10 +44,11 @@ class EightBall(commands.Cog, name="8ball"):
|
|||||||
"Very doubtful.",
|
"Very doubtful.",
|
||||||
]
|
]
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="**My Answer:**",
|
title="8 Ball",
|
||||||
description=f"{random.choice(answers)}",
|
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}")
|
embed.set_footer(text=f"The question was: {question}")
|
||||||
await context.send(embed=embed)
|
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 platform
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@@ -27,11 +19,11 @@ class BotInfo(commands.Cog, name="botinfo"):
|
|||||||
:param context: The hybrid command context.
|
:param context: The hybrid command context.
|
||||||
"""
|
"""
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
description="Used [Krypton's](https://krypton.ninja) template",
|
title="Nyrix Discord Bot",
|
||||||
color=0xBEBEFE,
|
color=0x7289DA,
|
||||||
)
|
)
|
||||||
embed.set_author(name="Bot Information")
|
embed.set_author(name="Bot Information", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||||
embed.add_field(name="Owner:", value="Krypton#7331", inline=True)
|
embed.add_field(name="Owner:", value="[neoarz](https://discordapp.com/users/1015372540937502851)", inline=True)
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Python Version:", value=f"{platform.python_version()}", inline=True
|
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",
|
value=f"/ (Slash Commands) or {self.bot.bot_prefix} for normal commands",
|
||||||
inline=False,
|
inline=False,
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"Requested by {context.author}")
|
|
||||||
await context.send(embed=embed)
|
await context.send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot) -> None:
|
async def setup(bot) -> None:
|
||||||
await bot.add_cog(BotInfo(bot))
|
await bot.add_cog(BotInfo(bot))
|
||||||
@@ -1,66 +1,58 @@
|
|||||||
"""
|
# import discord
|
||||||
Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja)
|
# from discord import app_commands
|
||||||
Description:
|
# from discord.ext import commands
|
||||||
🐍 A simple template to start to code your own and personalized Discord bot in Python
|
#
|
||||||
|
#
|
||||||
Version: 6.4.0
|
# class ContextMenus(commands.Cog, name="context_menus"):
|
||||||
"""
|
# def __init__(self, bot) -> None:
|
||||||
|
# self.bot = bot
|
||||||
import discord
|
# self.context_menu_user = app_commands.ContextMenu(
|
||||||
from discord import app_commands
|
# name="Grab ID", callback=self.grab_id
|
||||||
from discord.ext import commands
|
# )
|
||||||
|
# self.bot.tree.add_command(self.context_menu_user)
|
||||||
|
# self.context_menu_message = app_commands.ContextMenu(
|
||||||
class ContextMenus(commands.Cog, name="context_menus"):
|
# name="Remove spoilers", callback=self.remove_spoilers
|
||||||
def __init__(self, bot) -> None:
|
# )
|
||||||
self.bot = bot
|
# self.bot.tree.add_command(self.context_menu_message)
|
||||||
self.context_menu_user = app_commands.ContextMenu(
|
#
|
||||||
name="Grab ID", callback=self.grab_id
|
# async def remove_spoilers(
|
||||||
)
|
# self, interaction: discord.Interaction, message: discord.Message
|
||||||
self.bot.tree.add_command(self.context_menu_user)
|
# ) -> None:
|
||||||
self.context_menu_message = app_commands.ContextMenu(
|
# """
|
||||||
name="Remove spoilers", callback=self.remove_spoilers
|
# Removes the spoilers from the message. This command requires the MESSAGE_CONTENT intent to work properly.
|
||||||
)
|
#
|
||||||
self.bot.tree.add_command(self.context_menu_message)
|
# :param interaction: The application command interaction.
|
||||||
|
# :param message: The message that is being interacted with.
|
||||||
async def remove_spoilers(
|
# """
|
||||||
self, interaction: discord.Interaction, message: discord.Message
|
# spoiler_attachment = None
|
||||||
) -> None:
|
# for attachment in message.attachments:
|
||||||
"""
|
# if attachment.is_spoiler():
|
||||||
Removes the spoilers from the message. This command requires the MESSAGE_CONTENT intent to work properly.
|
# spoiler_attachment = attachment
|
||||||
|
# break
|
||||||
:param interaction: The application command interaction.
|
# embed = discord.Embed(
|
||||||
:param message: The message that is being interacted with.
|
# title="Message without spoilers",
|
||||||
"""
|
# description=message.content.replace("||", ""),
|
||||||
spoiler_attachment = None
|
# color=0xBEBEFE,
|
||||||
for attachment in message.attachments:
|
# )
|
||||||
if attachment.is_spoiler():
|
# if spoiler_attachment is not None:
|
||||||
spoiler_attachment = attachment
|
# embed.set_image(url=attachment.url)
|
||||||
break
|
# await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
embed = discord.Embed(
|
#
|
||||||
title="Message without spoilers",
|
# async def grab_id(
|
||||||
description=message.content.replace("||", ""),
|
# self, interaction: discord.Interaction, user: discord.User
|
||||||
color=0xBEBEFE,
|
# ) -> None:
|
||||||
)
|
# """
|
||||||
if spoiler_attachment is not None:
|
# Grabs the ID of the user.
|
||||||
embed.set_image(url=attachment.url)
|
#
|
||||||
await interaction.response.send_message(embed=embed, ephemeral=True)
|
# :param interaction: The application command interaction.
|
||||||
|
# :param user: The user that is being interacted with.
|
||||||
async def grab_id(
|
# """
|
||||||
self, interaction: discord.Interaction, user: discord.User
|
# embed = discord.Embed(
|
||||||
) -> None:
|
# description=f"The ID of {user.mention} is `{user.id}`.",
|
||||||
"""
|
# color=0xBEBEFE,
|
||||||
Grabs the ID of the user.
|
# )
|
||||||
|
# await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
:param interaction: The application command interaction.
|
#
|
||||||
:param user: The user that is being interacted with.
|
#
|
||||||
"""
|
# async def setup(bot) -> None:
|
||||||
embed = discord.Embed(
|
# await bot.add_cog(ContextMenus(bot))
|
||||||
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
|
import discord
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@@ -46,9 +38,10 @@ class Feedback(commands.Cog, name="feedback"):
|
|||||||
interaction = feedback_form.interaction
|
interaction = feedback_form.interaction
|
||||||
await interaction.response.send_message(
|
await interaction.response.send_message(
|
||||||
embed=discord.Embed(
|
embed=discord.Embed(
|
||||||
description="Thank you for your feedback, the owners have been notified about it.",
|
title="Thank You!",
|
||||||
color=0xBEBEFE,
|
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
|
app_owner = (await self.bot.application_info()).owner
|
||||||
@@ -56,8 +49,8 @@ class Feedback(commands.Cog, name="feedback"):
|
|||||||
embed=discord.Embed(
|
embed=discord.Embed(
|
||||||
title="New Feedback",
|
title="New Feedback",
|
||||||
description=f"{interaction.user} (<@{interaction.user.id}>) has submitted a new feedback:\n```\n{feedback_form.answer}\n```",
|
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",
|
"ping": "general",
|
||||||
"invite": "general",
|
"invite": "general",
|
||||||
"server": "general",
|
"server": "general",
|
||||||
"8ball": "general",
|
|
||||||
"feedback": "general",
|
"feedback": "general",
|
||||||
"context_menus": "general",
|
# "context_menus": "general",
|
||||||
|
|
||||||
"randomfact": "fun",
|
"randomfact": "fun",
|
||||||
"coinflip": "fun",
|
"coinflip": "fun",
|
||||||
"rps": "fun",
|
"rps": "fun",
|
||||||
|
"8ball": "fun",
|
||||||
|
|
||||||
"kick": "moderation",
|
"kick": "moderation",
|
||||||
"ban": "moderation",
|
"ban": "moderation",
|
||||||
|
|||||||
Reference in New Issue
Block a user