1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-03 05:23:11 +00:00
Lumi/modules/config/config.py

87 lines
3.1 KiB
Python
Raw Normal View History

2024-03-19 08:46:44 +00:00
import discord
from services.GuildConfig import GuildConfig
2024-03-19 09:05:43 +00:00
from main import strings
2024-03-19 08:46:44 +00:00
async def cmd(ctx):
guild_config = GuildConfig(ctx.guild.id)
embed = discord.Embed(
color = discord.Color.embed_background(),
title = f"{ctx.guild.name} configuration"
)
# birthdays
if guild_config.birthday_channel_id:
try:
channel = ctx.guild.get_channel(guild_config.birthday_channel_id)
2024-03-19 09:05:43 +00:00
birthday_config = f"✅ | in {channel.mention}."
2024-03-19 08:46:44 +00:00
except discord.HTTPException:
2024-03-19 09:05:43 +00:00
birthday_config = f"❌ | enable the module with `/config birthdays channel`"
2024-03-19 08:46:44 +00:00
else:
2024-03-19 09:05:43 +00:00
birthday_config = f"❌ | enable the module with `/config birthdays channel`"
2024-03-19 08:46:44 +00:00
2024-03-19 09:05:43 +00:00
embed.add_field(name="BIRTHDAYS", value=birthday_config, inline=False)
2024-03-19 08:46:44 +00:00
# commands
if guild_config.command_channel_id:
try:
channel = ctx.guild.get_channel(guild_config.command_channel_id)
2024-03-19 09:05:43 +00:00
commands_config = f"✅ | commands only allowed in {channel.mention}."
2024-03-19 08:46:44 +00:00
except discord.HTTPException:
2024-03-19 09:05:43 +00:00
commands_config = f"✅ | Commands allowed anywhere."
2024-03-19 08:46:44 +00:00
else:
2024-03-19 09:05:43 +00:00
commands_config = f"✅ | Commands allowed anywhere."
2024-03-19 08:46:44 +00:00
2024-03-19 09:05:43 +00:00
embed.add_field(name="COMMANDS", value=commands_config, inline=False)
2024-03-19 08:46:44 +00:00
# greetings
if guild_config.welcome_channel_id:
try:
channel = ctx.guild.get_channel(guild_config.welcome_channel_id)
2024-03-19 09:05:43 +00:00
greeting_config = f"✅ | in {channel.mention}"
2024-03-19 08:46:44 +00:00
2024-03-19 09:05:43 +00:00
if guild_config.welcome_message:
greeting_config += f" with template:\n```{guild_config.welcome_message}```"
else:
greeting_config += f" without custom template."
2024-03-19 08:46:44 +00:00
2024-03-19 09:05:43 +00:00
except discord.HTTPException:
greeting_config = f"❌ | enable the module with `/config greetings channel`"
2024-03-19 08:46:44 +00:00
else:
2024-03-19 09:05:43 +00:00
greeting_config = f"❌ | enable the module with `/config greetings channel`"
2024-03-19 08:46:44 +00:00
2024-03-19 09:05:43 +00:00
embed.add_field(name="GREETINGS", value=greeting_config, inline=False)
2024-03-19 08:46:44 +00:00
# levels
if guild_config.level_message_type == 0:
2024-03-19 09:05:43 +00:00
level_config = f"❌ | enable levels with `/config levels enable`"
2024-03-19 08:46:44 +00:00
elif guild_config.level_message_type == 1:
2024-03-19 09:05:43 +00:00
level_config = f"✅ | whimsical/sarcastic announcements"
2024-03-19 08:46:44 +00:00
else:
2024-03-19 09:05:43 +00:00
level_config = f"✅ | generic announcements"
2024-03-19 08:46:44 +00:00
if guild_config.level_channel_id and guild_config.level_message_type != 0:
try:
channel = ctx.guild.get_channel(guild_config.level_channel_id)
2024-03-19 09:05:43 +00:00
level_config += f" in {channel.mention}"
2024-03-19 08:46:44 +00:00
except discord.HTTPException:
2024-03-19 09:05:43 +00:00
level_config += f" in the user's current channel"
2024-03-19 08:46:44 +00:00
else:
if guild_config.level_message_type != 0:
2024-03-19 09:05:43 +00:00
level_config += f" in the user's current channel"
2024-03-19 08:46:44 +00:00
if guild_config.level_message and guild_config.level_message_type == 2:
2024-03-19 09:05:43 +00:00
level_config += f" with template:\n```{guild_config.level_message}```"
if not guild_config.level_message and guild_config.level_message_type == 2:
level_config += f" with template:\n```{strings['level_up']}```"
2024-03-19 08:46:44 +00:00
2024-03-19 09:05:43 +00:00
embed.add_field(name="LEVELS", value=level_config, inline=False)
2024-03-19 08:46:44 +00:00
await ctx.respond(embed=embed)