mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
feat: (description) move invite to make all general commands ep and more
Moved the invite command from general to owner cogs and updated help command category mapping accordingly. Improved ephemeral response handling in botinfo, ping, and serverinfo commands. Enhanced help command to avoid duplicate command listings and include application commands. Cleaned up serverinfo code and added guild-only enforcement.
This commit is contained in:
@@ -32,7 +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,
|
||||||
)
|
)
|
||||||
if context.interaction:
|
if getattr(context, "interaction", None):
|
||||||
await context.interaction.response.send_message(embed=embed, ephemeral=True)
|
await context.interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
else:
|
else:
|
||||||
await context.send(embed=embed)
|
await context.send(embed=embed)
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ class Feedback(commands.Cog, name="feedback"):
|
|||||||
title="Thank You!",
|
title="Thank You!",
|
||||||
description="Your feedback has been submitted, the owners have been notified about it.",
|
description="Your feedback has been submitted, the owners have been notified about it.",
|
||||||
color=0x7289DA,
|
color=0x7289DA,
|
||||||
).set_author(name="Feedback System", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
).set_author(name="Feedback System", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp"),
|
||||||
|
ephemeral=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
app_owner = (await self.bot.application_info()).owner
|
app_owner = (await self.bot.application_info()).owner
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class Help(commands.Cog, name="help"):
|
|||||||
"botinfo": "general",
|
"botinfo": "general",
|
||||||
"serverinfo": "general",
|
"serverinfo": "general",
|
||||||
"ping": "general",
|
"ping": "general",
|
||||||
"invite": "general",
|
|
||||||
"feedback": "general",
|
"feedback": "general",
|
||||||
# "context_menus": "general",
|
# "context_menus": "general",
|
||||||
|
|
||||||
@@ -63,6 +62,7 @@ class Help(commands.Cog, name="help"):
|
|||||||
"cog_management": "owner",
|
"cog_management": "owner",
|
||||||
"shutdown": "owner",
|
"shutdown": "owner",
|
||||||
"say": "owner",
|
"say": "owner",
|
||||||
|
"invite": "owner",
|
||||||
|
|
||||||
"testcommand": "template"
|
"testcommand": "template"
|
||||||
}
|
}
|
||||||
@@ -134,14 +134,32 @@ class Help(commands.Cog, name="help"):
|
|||||||
return
|
return
|
||||||
|
|
||||||
commands_in_category = []
|
commands_in_category = []
|
||||||
|
seen_names = set()
|
||||||
for cog_name in self.bot.cogs:
|
for cog_name in self.bot.cogs:
|
||||||
if category_mapping.get(cog_name.lower()) == category:
|
if category_mapping.get(cog_name.lower()) == category:
|
||||||
cog = self.bot.get_cog(cog_name)
|
cog = self.bot.get_cog(cog_name)
|
||||||
if cog:
|
if cog:
|
||||||
commands_list = cog.get_commands()
|
commands_list = cog.get_commands()
|
||||||
for command in commands_list:
|
for command in commands_list:
|
||||||
|
name = command.name
|
||||||
|
if name in seen_names:
|
||||||
|
continue
|
||||||
description = command.description.partition("\n")[0] if command.description else "No description available"
|
description = command.description.partition("\n")[0] if command.description else "No description available"
|
||||||
commands_in_category.append((command.name, description))
|
commands_in_category.append((name, description))
|
||||||
|
seen_names.add(name)
|
||||||
|
|
||||||
|
for app_command in self.bot.tree.get_commands():
|
||||||
|
bound_cog = getattr(app_command, "binding", None)
|
||||||
|
if bound_cog is None:
|
||||||
|
continue
|
||||||
|
bound_cog_name = getattr(bound_cog, "qualified_name", "").lower()
|
||||||
|
if category_mapping.get(bound_cog_name) != category:
|
||||||
|
continue
|
||||||
|
if app_command.name in seen_names:
|
||||||
|
continue
|
||||||
|
description = app_command.description.partition("\n")[0] if getattr(app_command, "description", None) else "No description available"
|
||||||
|
commands_in_category.append((app_command.name, description))
|
||||||
|
seen_names.add(app_command.name)
|
||||||
|
|
||||||
if not commands_in_category:
|
if not commands_in_category:
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ class Ping(commands.Cog, name="ping"):
|
|||||||
color=0xBEBEFE,
|
color=0xBEBEFE,
|
||||||
)
|
)
|
||||||
embed.set_author(name="Ping", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
embed.set_author(name="Ping", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||||
await context.send(embed=embed)
|
if getattr(context, "interaction", None):
|
||||||
|
await context.interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
|
else:
|
||||||
|
await context.send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot) -> None:
|
async def setup(bot) -> None:
|
||||||
|
|||||||
@@ -1,16 +1,7 @@
|
|||||||
"""
|
|
||||||
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.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import Context
|
from discord.ext.commands import Context
|
||||||
|
|
||||||
|
|
||||||
class ServerInfo(commands.Cog, name="serverinfo"):
|
class ServerInfo(commands.Cog, name="serverinfo"):
|
||||||
def __init__(self, bot) -> None:
|
def __init__(self, bot) -> None:
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
@@ -19,12 +10,17 @@ class ServerInfo(commands.Cog, name="serverinfo"):
|
|||||||
name="serverinfo",
|
name="serverinfo",
|
||||||
description="Get some useful (or not) information about the server.",
|
description="Get some useful (or not) information about the server.",
|
||||||
)
|
)
|
||||||
|
@commands.guild_only() # This decorator ensures the command only works in servers
|
||||||
async def serverinfo(self, context: Context) -> None:
|
async def serverinfo(self, context: Context) -> None:
|
||||||
"""
|
"""
|
||||||
Get some useful (or not) information about the server.
|
Get some useful (or not) information about the server.
|
||||||
|
|
||||||
:param context: The hybrid command context.
|
:param context: The hybrid command context.
|
||||||
"""
|
"""
|
||||||
|
# Additional check (though @commands.guild_only() should handle this)
|
||||||
|
if context.guild is None:
|
||||||
|
await context.send("This command can only be used in a server, not in DMs!")
|
||||||
|
return
|
||||||
|
|
||||||
roles = [role.name for role in context.guild.roles]
|
roles = [role.name for role in context.guild.roles]
|
||||||
num_roles = len(roles)
|
num_roles = len(roles)
|
||||||
if num_roles > 50:
|
if num_roles > 50:
|
||||||
@@ -33,19 +29,31 @@ class ServerInfo(commands.Cog, name="serverinfo"):
|
|||||||
roles = ", ".join(roles)
|
roles = ", ".join(roles)
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="**Server Name:**", description=f"{context.guild}", color=0xBEBEFE
|
title="**Server Name:**",
|
||||||
)
|
description=f"{context.guild}",
|
||||||
|
color=0x7289DA
|
||||||
|
).set_author(name="Server Information", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||||
|
|
||||||
if context.guild.icon is not None:
|
if context.guild.icon is not None:
|
||||||
embed.set_thumbnail(url=context.guild.icon.url)
|
embed.set_thumbnail(url=context.guild.icon.url)
|
||||||
|
|
||||||
embed.add_field(name="Server ID", value=context.guild.id)
|
embed.add_field(name="Server ID", value=context.guild.id)
|
||||||
embed.add_field(name="Member Count", value=context.guild.member_count)
|
embed.add_field(name="Member Count", value=context.guild.member_count)
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Text/Voice Channels", value=f"{len(context.guild.channels)}"
|
name="Text/Voice Channels",
|
||||||
|
value=f"{len(context.guild.channels)}"
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name=f"Roles ({len(context.guild.roles)})",
|
||||||
|
value=roles
|
||||||
)
|
)
|
||||||
embed.add_field(name=f"Roles ({len(context.guild.roles)})", value=roles)
|
|
||||||
embed.set_footer(text=f"Created at: {context.guild.created_at}")
|
embed.set_footer(text=f"Created at: {context.guild.created_at}")
|
||||||
await context.send(embed=embed)
|
|
||||||
|
|
||||||
|
if getattr(context, "interaction", None):
|
||||||
|
await context.interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
|
else:
|
||||||
|
await context.send(embed=embed)
|
||||||
|
|
||||||
async def setup(bot) -> None:
|
async def setup(bot) -> None:
|
||||||
await bot.add_cog(ServerInfo(bot))
|
await bot.add_cog(ServerInfo(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 os
|
import os
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
Reference in New Issue
Block a user