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

chore: Add birthday module configuration commands

This commit is contained in:
wlinator 2024-08-03 13:33:01 -04:00
parent c009fd5412
commit 50da9fcf24
4 changed files with 52 additions and 90 deletions

View file

@ -22,6 +22,7 @@
"case_type_field": "Type:", "case_type_field": "Type:",
"case_type_field_value": "`{0}`", "case_type_field_value": "`{0}`",
"case_type_field_value_with_duration": "`{0} ({1})`", "case_type_field_value_with_duration": "`{0} ({1})`",
"config_author": "Server Configuration",
"config_show_author": "{0} Configuration", "config_show_author": "{0} Configuration",
"config_show_birthdays": "Birthdays", "config_show_birthdays": "Birthdays",
"config_show_boost_announcements": "Boost announcements", "config_show_boost_announcements": "Boost announcements",
@ -35,6 +36,9 @@
"config_show_moderation_log_enabled": "✅ {0}", "config_show_moderation_log_enabled": "✅ {0}",
"config_show_moderation_log_not_configured": "⚠️ **Not configured yet**", "config_show_moderation_log_not_configured": "⚠️ **Not configured yet**",
"config_show_new_member_greets": "New member greets", "config_show_new_member_greets": "New member greets",
"config_birthday_channel_set": "birthday announcements will be sent in {0}.",
"config_birthday_module_already_disabled": "the birthday module was already disabled.",
"config_birthday_module_disabled": "the birthday module was successfully disabled.",
"daily_already_claimed_author": "Already Claimed", "daily_already_claimed_author": "Already Claimed",
"daily_already_claimed_description": "you can claim your daily reward again <t:{0}:R>.", "daily_already_claimed_description": "you can claim your daily reward again <t:{0}:R>.",
"daily_already_claimed_footer": "Daily reset is at 7 AM EST", "daily_already_claimed_footer": "Daily reset is at 7 AM EST",

View file

@ -7,7 +7,7 @@ from lib import formatter
from lib.embeds.boost import Boost from lib.embeds.boost import Boost
from lib.embeds.error import GenericErrors from lib.embeds.error import GenericErrors
from lib.embeds.greet import Greet from lib.embeds.greet import Greet
from modules.config import show, set_prefix, xp_reward from modules.config import c_show, c_birthday, set_prefix, xp_reward
from services.config_service import GuildConfig from services.config_service import GuildConfig
strings = JsonCache.read_json("strings") strings = JsonCache.read_json("strings")
@ -78,8 +78,6 @@ class Config(commands.Cog):
Only members with "manage guild" permissions can access commands in this group. Only members with "manage guild" permissions can access commands in this group.
- Birthdays - Birthdays
- Commands
- Intros
- Welcome - Welcome
- Boosts - Boosts
- Levels - Levels
@ -96,103 +94,21 @@ class Config(commands.Cog):
default_member_permissions=discord.Permissions(manage_guild=True), default_member_permissions=discord.Permissions(manage_guild=True),
) )
birthday_config = config.create_subgroup(name="birthdays") birthday_config = config.create_subgroup(name="birthdays")
command_config = config.create_subgroup(name="commands")
intro_config = config.create_subgroup(name="intros")
welcome_config = config.create_subgroup(name="greetings") welcome_config = config.create_subgroup(name="greetings")
boost_config = config.create_subgroup(name="boosts") boost_config = config.create_subgroup(name="boosts")
level_config = config.create_subgroup(name="levels") level_config = config.create_subgroup(name="levels")
@config.command(name="show") @config.command(name="show")
async def config_command(self, ctx): async def config_command(self, ctx):
await show.cmd(ctx) await c_show.cmd(ctx)
@birthday_config.command( @birthday_config.command(name="channel")
name="channel",
description="Set the birthday announcements channel.",
)
async def config_birthdays_channel(self, ctx, *, channel: discord.TextChannel): async def config_birthdays_channel(self, ctx, *, channel: discord.TextChannel):
guild_config = GuildConfig(ctx.guild.id) await c_birthday.set_birthday_channel(ctx, channel)
guild_config.birthday_channel_id = channel.id
guild_config.push()
embed = discord.Embed( @birthday_config.command(name="disable")
color=discord.Color.orange(),
description=f"✅ | Birthday announcements will be sent in {channel.mention}.",
)
guild_icon = (
ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
)
embed.set_author(name="Server Configuration", icon_url=guild_icon)
return await ctx.respond(embed=embed)
@birthday_config.command(
name="disable",
description="Disable the birthday module.",
)
async def config_birthdays_disable(self, ctx): async def config_birthdays_disable(self, ctx):
guild_config = GuildConfig(ctx.guild.id) await c_birthday.disable_birthday_module(ctx)
embed = discord.Embed(
color=discord.Color.orange(),
)
guild_icon = (
ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
)
embed.set_author(name="Server Configuration", icon_url=guild_icon)
if not guild_config.birthday_channel_id:
embed.description = "👍 | The birthday module was already disabled."
return await ctx.respond(embed=embed)
else:
guild_config.birthday_channel_id = None
guild_config.push()
embed.description = "✅ | The birthday module was successfully disabled."
return await ctx.respond(embed=embed)
@command_config.command(
name="channel",
description="Configure where members can use Lumi commands.",
)
async def config_commands_channel(self, ctx, *, channel: discord.TextChannel):
guild_config = GuildConfig(ctx.guild.id)
guild_config.command_channel_id = channel.id
guild_config.push()
embed = discord.Embed(
color=discord.Color.orange(),
description=f"✅ | Commands can now only be used in {channel.mention}.",
)
guild_icon = (
ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
)
embed.set_author(name="Server Configuration", icon_url=guild_icon)
embed.set_footer(
text="Note: mod & config commands are still available everywhere.",
)
return await ctx.respond(embed=embed)
@command_config.command(
name="everywhere",
description="Allow members to do commands in all channels.",
)
async def config_commands_everywhere(self, ctx):
guild_config = GuildConfig(ctx.guild.id)
guild_config.command_channel_id = None
guild_config.push()
embed = discord.Embed(
color=discord.Color.orange(),
description="✅ | Server members can now use Lumi commands in all channels. ",
)
guild_icon = (
ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
)
embed.set_author(name="Server Configuration", icon_url=guild_icon)
return await ctx.respond(embed=embed)
@welcome_config.command( @welcome_config.command(
name="channel", name="channel",

View file

@ -0,0 +1,42 @@
import discord
from lib.embed_builder import EmbedBuilder
from lib.constants import CONST
from services.config_service import GuildConfig
async def set_birthday_channel(ctx, channel: discord.TextChannel):
guild_config = GuildConfig(ctx.guild.id)
guild_config.birthday_channel_id = channel.id
guild_config.push()
embed = EmbedBuilder().create_success_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_birthday_channel_set"].format(
channel.mention,
),
)
return await ctx.respond(embed=embed)
async def disable_birthday_module(ctx):
guild_config = GuildConfig(ctx.guild.id)
if not guild_config.birthday_channel_id:
embed = EmbedBuilder().create_warning_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_birthday_module_already_disabled"],
)
else:
embed = EmbedBuilder().create_success_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_birthday_module_disabled"],
)
guild_config.birthday_channel_id = None
guild_config.push()
return await ctx.respond(embed=embed)