mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 19:50:12 +01:00
initial commit
This commit is contained in:
20
cogs/livecontainer/26jit.py
Normal file
20
cogs/livecontainer/26jit.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
|
||||
def jit26_command():
|
||||
async def command(self, context: Context):
|
||||
embed = discord.Embed(
|
||||
title="Hello World",
|
||||
description="hello world",
|
||||
color=0x0169FF,
|
||||
)
|
||||
|
||||
if context.interaction:
|
||||
await context.interaction.response.send_message(embed=embed, ephemeral=True)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
return command
|
||||
|
||||
91
cogs/livecontainer/__init__.py
Normal file
91
cogs/livecontainer/__init__.py
Normal file
@@ -0,0 +1,91 @@
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from .livecontainer import LivecontainerView
|
||||
from .jit26 import jit26_command
|
||||
|
||||
|
||||
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
|
||||
@app_commands.allowed_installs(guilds=True, users=True)
|
||||
class Livecontainer(commands.GroupCog, name="livecontainer"):
|
||||
def __init__(self, bot) -> None:
|
||||
self.bot = bot
|
||||
super().__init__()
|
||||
|
||||
@commands.group(name="livecontainer", invoke_without_command=True)
|
||||
async def livecontainer_group(self, context: Context):
|
||||
embed = discord.Embed(
|
||||
title="LiveContainer Commands",
|
||||
description="Choose a command from the dropdown below to get help with specific issues:",
|
||||
color=0x0169FF,
|
||||
)
|
||||
embed.set_author(
|
||||
name="LiveContainer", icon_url="https://raw.githubusercontent.com/LiveContainer/LiveContainer/main/screenshots/livecontainer_icon.png"
|
||||
)
|
||||
view = LivecontainerView(self.bot)
|
||||
await context.send(embed=embed, view=view)
|
||||
|
||||
@livecontainer_group.command(name="help")
|
||||
async def livecontainer_group_help(self, context: Context):
|
||||
embed = discord.Embed(
|
||||
title="LiveContainer Commands",
|
||||
description="Choose a command from the dropdown below to get help with specific issues:",
|
||||
color=0x0169FF,
|
||||
)
|
||||
embed.set_author(
|
||||
name="LiveContainer", icon_url="https://raw.githubusercontent.com/LiveContainer/LiveContainer/main/screenshots/livecontainer_icon.png"
|
||||
)
|
||||
view = LivecontainerView(self.bot)
|
||||
await context.send(embed=embed, view=view)
|
||||
|
||||
@livecontainer_group.command(name="26jit")
|
||||
async def livecontainer_group_26jit(self, context: Context):
|
||||
await self._invoke_hybrid(context, "26jit")
|
||||
|
||||
async def _invoke_hybrid(self, context: Context, name: str):
|
||||
command = self.bot.get_command(name)
|
||||
if command is not None:
|
||||
await context.invoke(command)
|
||||
else:
|
||||
await context.send(f"Unknown LiveContainer command: {name}")
|
||||
|
||||
def _require_group_prefix(context: Context) -> bool:
|
||||
if getattr(context, "interaction", None):
|
||||
return True
|
||||
group = getattr(getattr(context, "cog", None), "qualified_name", "").lower()
|
||||
if not group:
|
||||
return True
|
||||
prefix = context.prefix or ""
|
||||
content = context.message.content.strip().lower()
|
||||
return content.startswith(f"{prefix}{group} ")
|
||||
|
||||
@app_commands.command(name="help", description="LiveContainer troubleshooting help")
|
||||
async def help(self, interaction: discord.Interaction):
|
||||
embed = discord.Embed(
|
||||
title="LiveContainer Commands",
|
||||
description="Choose a command from the dropdown below to get help with specific issues:",
|
||||
color=0x0169FF,
|
||||
)
|
||||
embed.set_author(
|
||||
name="LiveContainer", icon_url="https://raw.githubusercontent.com/LiveContainer/LiveContainer/main/screenshots/livecontainer_icon.png"
|
||||
)
|
||||
view = LivecontainerView(self.bot)
|
||||
await interaction.response.send_message(embed=embed, view=view, ephemeral=True)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="26jit", description="26JIT information"
|
||||
)
|
||||
async def jit26(self, context):
|
||||
return await jit26_command()(self, context)
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
cog = Livecontainer(bot)
|
||||
await bot.add_cog(cog)
|
||||
|
||||
bot.logger.info("Loaded extension 'livecontainer.help'")
|
||||
bot.logger.info("Loaded extension 'livecontainer.26jit'")
|
||||
|
||||
19
cogs/livecontainer/jit26.py
Normal file
19
cogs/livecontainer/jit26.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import discord
|
||||
from discord.ext.commands import Context
|
||||
|
||||
|
||||
def jit26_command():
|
||||
async def command(self, context: Context):
|
||||
embed = discord.Embed(
|
||||
title="Hello World",
|
||||
description="hello world",
|
||||
color=0x0169FF,
|
||||
)
|
||||
|
||||
if context.interaction:
|
||||
await context.interaction.response.send_message(embed=embed)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
return command
|
||||
|
||||
88
cogs/livecontainer/livecontainer.py
Normal file
88
cogs/livecontainer/livecontainer.py
Normal file
@@ -0,0 +1,88 @@
|
||||
import discord
|
||||
|
||||
|
||||
class LivecontainerSelect(discord.ui.Select):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
options = [
|
||||
discord.SelectOption(
|
||||
label="26JIT",
|
||||
value="26jit",
|
||||
description="26JIT information",
|
||||
),
|
||||
]
|
||||
super().__init__(placeholder="Choose a LiveContainer command...", options=options)
|
||||
|
||||
async def callback(self, interaction: discord.Interaction):
|
||||
command_name = self.values[0]
|
||||
command = self.bot.get_command(command_name)
|
||||
|
||||
if command:
|
||||
try:
|
||||
ctx = await self.bot.get_context(interaction.message)
|
||||
if ctx:
|
||||
await ctx.invoke(command)
|
||||
embed = discord.Embed(
|
||||
title="Command Executed",
|
||||
description=f"Successfully executed `/{command_name}`",
|
||||
color=0x00FF00,
|
||||
)
|
||||
embed.set_author(
|
||||
name="LiveContainer",
|
||||
icon_url="https://raw.githubusercontent.com/LiveContainer/LiveContainer/main/screenshots/livecontainer_icon.png",
|
||||
)
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
except discord.Forbidden:
|
||||
guild_info = (
|
||||
f"server {interaction.guild.name} (ID: {interaction.guild.id})"
|
||||
if interaction.guild
|
||||
else "DM or private channel"
|
||||
)
|
||||
self.bot.logger.warning(
|
||||
f"Bot missing permissions in {guild_info} - cannot execute {command_name} command"
|
||||
)
|
||||
|
||||
if interaction.guild is None:
|
||||
embed = discord.Embed(
|
||||
title="Error",
|
||||
description="This command cannot be executed in DMs.",
|
||||
color=0xFF0000,
|
||||
)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title="Permission Error",
|
||||
description="The bot needs the `send messages` permission to execute this command.",
|
||||
color=0xFF0000,
|
||||
)
|
||||
embed.set_author(
|
||||
name="LiveContainer",
|
||||
icon_url="https://raw.githubusercontent.com/LiveContainer/LiveContainer/main/screenshots/livecontainer_icon.png",
|
||||
)
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
except Exception as e:
|
||||
self.bot.logger.error(f"Error executing {command_name} command: {e}")
|
||||
embed = discord.Embed(
|
||||
title="Error",
|
||||
description="An error occurred while executing the command.",
|
||||
color=0xFF0000,
|
||||
)
|
||||
embed.set_author(
|
||||
name="LiveContainer",
|
||||
icon_url="https://raw.githubusercontent.com/LiveContainer/LiveContainer/main/screenshots/livecontainer_icon.png",
|
||||
)
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title="Error", description="Command not found!", color=0xFF0000
|
||||
)
|
||||
embed.set_author(
|
||||
name="LiveContainer",
|
||||
icon_url="https://raw.githubusercontent.com/LiveContainer/LiveContainer/main/screenshots/livecontainer_icon.png",
|
||||
)
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
|
||||
|
||||
class LivecontainerView(discord.ui.View):
|
||||
def __init__(self, bot):
|
||||
super().__init__()
|
||||
self.add_item(LivecontainerSelect(bot))
|
||||
Reference in New Issue
Block a user