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

chore: Add birthday module configuration commands

This commit is contained in:
wlinator 2024-08-03 13:51:44 -04:00
parent 50da9fcf24
commit d5c8d56341
3 changed files with 80 additions and 74 deletions

View file

@ -23,6 +23,9 @@
"case_type_field_value": "`{0}`",
"case_type_field_value_with_duration": "`{0} ({1})`",
"config_author": "Server Configuration",
"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.",
"config_show_author": "{0} Configuration",
"config_show_birthdays": "Birthdays",
"config_show_boost_announcements": "Boost announcements",
@ -36,9 +39,12 @@
"config_show_moderation_log_enabled": "✅ {0}",
"config_show_moderation_log_not_configured": "⚠️ **Not configured yet**",
"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.",
"config_welcome_channel_set": "I will announce new members in {0}.",
"config_welcome_module_already_disabled": "the greeting module was already disabled.",
"config_welcome_module_disabled": "the greeting module was successfully disabled.",
"config_welcome_template_field": "New Template:",
"config_welcome_template_updated": "the welcome message template has been updated.",
"config_welcome_template_updated_footer": "An example will be sent next.",
"daily_already_claimed_author": "Already Claimed",
"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",

View file

@ -6,8 +6,7 @@ from config.parser import JsonCache
from lib import formatter
from lib.embeds.boost import Boost
from lib.embeds.error import GenericErrors
from lib.embeds.greet import Greet
from modules.config import c_show, c_birthday, set_prefix, xp_reward
from modules.config import c_show, c_birthday, c_greet, set_prefix, xp_reward
from services.config_service import GuildConfig
strings = JsonCache.read_json("strings")
@ -110,84 +109,21 @@ class Config(commands.Cog):
async def config_birthdays_disable(self, ctx):
await c_birthday.disable_birthday_module(ctx)
@welcome_config.command(
name="channel",
description="Set the greeting announcements channel.",
)
@welcome_config.command(name="channel")
async def config_welcome_channel(self, ctx, *, channel: discord.TextChannel):
guild_config = GuildConfig(ctx.guild.id)
guild_config.welcome_channel_id = channel.id
guild_config.push()
await c_greet.set_welcome_channel(ctx, channel)
embed = discord.Embed(
color=discord.Color.orange(),
description=f"✅ | New members will receive a welcome message 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)
@welcome_config.command(
name="disable",
description="Disable greetings in this server.",
)
@welcome_config.command(name="disable")
async def config_welcome_disable(self, ctx):
guild_config = GuildConfig(ctx.guild.id)
await c_greet.disable_welcome_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.welcome_channel_id:
embed.description = "👍 | The greeting module was already disabled."
return await ctx.respond(embed=embed)
else:
guild_config.welcome_channel_id = None
guild_config.welcome_message = None
guild_config.push()
embed.description = "✅ | The greeting module was successfully disabled."
return await ctx.respond(embed=embed)
@welcome_config.command(
name="template",
description="Make a custom greeting template.",
)
@welcome_config.command(name="template")
async def config_welcome_template(
self,
ctx,
*,
text: discord.Option(str, max_length=2000),
):
guild_config = GuildConfig(ctx.guild.id)
guild_config.welcome_message = text
guild_config.push()
embed = discord.Embed(
color=discord.Color.orange(),
description="✅ | The greeting template was successfully updated.",
)
guild_icon = (
ctx.guild.icon if ctx.guild.icon else "https://i.imgur.com/79XfsbS.png"
)
embed.add_field(name="Template", value=text, inline=False)
embed.add_field(
name="Example",
value="An example will be sent in a separate message.",
inline=False,
)
embed.set_author(name="Server Configuration", icon_url=guild_icon)
await ctx.respond(embed=embed)
embed = Greet.message(ctx.author, text)
return await ctx.send(embed=embed, content=ctx.author.mention)
await c_greet.set_welcome_template(ctx, text)
@boost_config.command(
name="channel",

64
modules/config/c_greet.py Normal file
View file

@ -0,0 +1,64 @@
import discord
from lib.embed_builder import EmbedBuilder
from lib.constants import CONST
from services.config_service import GuildConfig
from lib.embeds.greet import Greet
async def set_welcome_channel(ctx, channel: discord.TextChannel):
guild_config = GuildConfig(ctx.guild.id)
guild_config.welcome_channel_id = channel.id
guild_config.push()
embed = EmbedBuilder().create_success_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_welcome_channel_set"].format(channel.mention),
)
return await ctx.respond(embed=embed)
async def disable_welcome_module(ctx):
guild_config = GuildConfig(ctx.guild.id)
if not guild_config.welcome_channel_id:
embed = EmbedBuilder().create_warning_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_welcome_module_already_disabled"],
)
else:
guild_config.welcome_channel_id = None
guild_config.welcome_message = None
guild_config.push()
embed = EmbedBuilder().create_success_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_welcome_module_disabled"],
)
return await ctx.respond(embed=embed)
async def set_welcome_template(ctx, text: str):
guild_config = GuildConfig(ctx.guild.id)
guild_config.welcome_message = text
guild_config.push()
embed = EmbedBuilder().create_success_embed(
ctx=ctx,
author_text=CONST.STRINGS["config_author"],
description=CONST.STRINGS["config_welcome_template_updated"],
footer_text=CONST.STRINGS["config_welcome_template_updated_footer"],
)
embed.add_field(
name=CONST.STRINGS["config_welcome_template_field"],
value=f"```{text}```",
inline=False,
)
await ctx.respond(embed=embed)
example_embed = Greet.message(ctx.author, text)
return await ctx.send(embed=example_embed, content=ctx.author.mention)