feat(commands/administration): adding the welcome show command

This commit is contained in:
Raphael 2025-11-24 23:21:15 +01:00 committed by Raphaël
parent 0db6014b72
commit 7061a98373

View file

@ -12,7 +12,11 @@ import {
ChannelSelectMenuInteraction, ChannelSelectMenuInteraction,
GuildBasedChannel, GuildBasedChannel,
TextInputStyle, TextInputStyle,
MessageComponentInteraction,
CacheType,
} from 'discord.js'; } from 'discord.js';
import { channelMention, EmbedBuilder } from '@discordjs/builders';
import { Guild as GuildPrisma } from '@prisma/client';
import { prisma } from '@lib/prisma'; import { prisma } from '@lib/prisma';
import emoji from '../../../assets/emoji.json' assert { type: 'json' }; import emoji from '../../../assets/emoji.json' assert { type: 'json' };
@ -49,10 +53,35 @@ export default {
}); });
return; return;
} }
const guildData: GuildPrisma = await prisma.guild.findUnique({
where: {
id: interaction.guild.id,
},
});
const choice: string = interaction.options.getString('action', true); const choice: string = interaction.options.getString('action', true);
switch (choice) { switch (choice) {
case 'welcome_show': {
const status: EmbedBuilder = new EmbedBuilder()
.setTitle(`Welcome status for ${interaction.guild.name}`)
.setColor(guildData.color)
.setFooter({
text: guildData.footer,
})
.setDescription(`
${guildData.joinEnabled ? `${emoji.config.enable}` : `${emoji.config.disable}`} **Join message:**
${guildData.joinEnabled ? `> in ${channelMention(guildData.joinChannel)} with the message \`${guildData.joinMessage}\`\n` : ''}
${guildData.leaveEnabled ? `${emoji.config.enable}` : `${emoji.config.disable}`} **Leave message:**
${guildData.leaveEnabled ? `> in ${channelMention(guildData.joinChannel)} with the message \`${guildData.leaveMessage}\`` : ''}
`);
await interaction.reply({
embeds: [status],
flags: MessageFlags.Ephemeral,
});
break;
}
case 'welcome_join': { case 'welcome_join': {
const joinSelectMenu: ChannelSelectMenuBuilder = new ChannelSelectMenuBuilder() const joinSelectMenu: ChannelSelectMenuBuilder = new ChannelSelectMenuBuilder()
.setCustomId('join_select_channel') .setCustomId('join_select_channel')