1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:23:12 +00:00

Add more functionality to dev commands & add config birthday commands

This commit is contained in:
wlinator 2024-08-29 15:40:24 -04:00
parent dafaff56bd
commit b36a9ae1b6
5 changed files with 125 additions and 44 deletions

View file

@ -140,6 +140,8 @@
"daily_success_claim_author": "Reward Claimed",
"daily_success_claim_description": "you claimed your reward of **${0}**!",
"default_level_up_message": "**{0}** you have reached **Level {1}**.",
"dev_clear_tree": "The application command tree has been cleared.",
"dev_sync_tree": "The application command tree has been synced.",
"error_actionable_hierarchy_bot": "I don't have permission to perform this action on this user due to role hierarchy.",
"error_actionable_hierarchy_user": "you don't have permission to perform this action on this user due to role hierarchy.",
"error_actionable_self": "you can't perform this action on yourself.",
@ -259,8 +261,6 @@
"slowmode_success": "Slowmode set to **{0}s** in {1}.",
"stats_blackjack": "\ud83c\udccf | You've played **{0}** games of BlackJack, betting a total of **${1}**. You won **{2}** of those games with a total payout of **${3}**.",
"stats_slots": "\ud83c\udfb0 | You've played **{0}** games of Slots, betting a total of **${1}**. Your total payout was **${2}**.",
"sync_author": "Synced Commands",
"sync_description": "the application command tree has been synced.",
"trigger_already_exists": "Failed to add custom reaction. This text already contains another trigger. To avoid unexpected behavior, please delete it before adding a new one.",
"trigger_limit_reached": "Failed to add custom reaction. You have reached the limit of 100 custom reactions for this server.",
"triggers_add_author": "Custom Reaction Created",

46
modules/admin/dev.py Normal file
View file

@ -0,0 +1,46 @@
import discord
from discord.ext import commands
from lib.const import CONST
class Dev(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.group(name="dev", description="Lumi developer commands")
@commands.guild_only()
@commands.is_owner()
async def dev(self, ctx: commands.Context[commands.Bot]) -> None:
pass
@dev.command(
name="sync_tree",
aliases=["sync"],
usage="sync_tree [guild]",
)
async def sync(
self,
ctx: commands.Context[commands.Bot],
guild: discord.Guild | None = None,
) -> None:
if guild:
self.bot.tree.copy_global_to(guild=guild)
await self.bot.tree.sync(guild=guild)
await ctx.send(content=CONST.STRINGS["dev_sync_tree"])
@dev.command(name="clear_tree", aliases=["clear"])
async def sync_global(
self,
ctx: commands.Context[commands.Bot],
guild: discord.Guild | None = None,
) -> None:
self.bot.tree.clear_commands(guild=guild)
await ctx.send(content=CONST.STRINGS["dev_clear_tree"])
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Dev(bot))

View file

@ -1,42 +0,0 @@
import discord
from discord.ext import commands
from lib.const import CONST
from ui.embeds import Builder
class Sync(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(
name="sync",
usage="sync [guild]",
)
@commands.guild_only()
@commands.is_owner()
async def sync(
self,
ctx: commands.Context[commands.Bot],
guild: discord.Guild | None = None,
) -> None:
if not guild:
guild = ctx.guild
assert guild
self.bot.tree.copy_global_to(guild=guild)
await self.bot.tree.sync(guild=guild)
embed = Builder.create_embed(
theme="success",
user_name=ctx.author.name,
author_text=CONST.STRINGS["sync_author"],
description=CONST.STRINGS["sync_description"],
)
await ctx.send(embed=embed)
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Sync(bot))

View file

@ -0,0 +1,11 @@
from discord.ext import commands
from modules.config.c_birthday import BirthdayConfig
class Config(BirthdayConfig, group_name="config"):
pass
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Config(bot))

View file

@ -0,0 +1,66 @@
import discord
from discord import app_commands
from discord.ext import commands
from lib.const import CONST
from services.config_service import GuildConfig
from ui.embeds import Builder
class BirthdayConfig(commands.GroupCog, group_name="config"):
def __init__(self, bot: commands.Bot):
self.bot = bot
birthday = app_commands.Group(name="birthday", description="Birthday commands")
@birthday.command(name="channel", description="Set the birthday announcement channel")
@app_commands.describe(channel="The channel to set for birthday announcements")
async def birthday_channel(self, interaction: discord.Interaction, channel: discord.TextChannel) -> None:
if not interaction.guild:
return
guild_config = GuildConfig(interaction.guild.id)
guild_config.birthday_channel_id = channel.id
guild_config.push()
embed = Builder.create_embed(
theme="success",
user_name=interaction.user.name,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_birthday_channel_set"].format(
channel.mention,
),
)
await interaction.response.send_message(embed=embed)
@birthday.command(name="disable", description="Disable the birthday module")
async def birthday_disable(self, interaction: discord.Interaction) -> None:
if not interaction.guild:
return
guild_config = GuildConfig(interaction.guild.id)
if not guild_config.birthday_channel_id:
embed = Builder.create_embed(
theme="warning",
user_name=interaction.user.name,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_birthday_module_already_disabled"],
)
else:
embed = Builder.create_embed(
theme="success",
user_name=interaction.user.name,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_birthday_module_disabled"],
)
guild_config.birthday_channel_id = None
guild_config.push()
await interaction.response.send_message(embed=embed)
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(BirthdayConfig(bot))