diff --git a/src/commands/example_all.test.ts b/src/commands/example_all.test.ts deleted file mode 100644 index 417355c..0000000 --- a/src/commands/example_all.test.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { - SlashCommandBuilder, - EmbedBuilder, -} from "discord.js"; -import { Command } from "../base/classes/command.js"; - -export default new Command({ - info: new SlashCommandBuilder() - .setName("example_all") - .setDescription("[TEMP] Preview all bot messages and embeds"), - async execute(interaction) { - await interaction.deferReply(); - - // 1. Boost start greet embed - const greetEmbed = new EmbedBuilder() - .setColor(0xf47fff) - .setTitle("New Server Boost") - .setDescription(`${interaction.user} has boosted the server.`) - .addFields( - { name: "Total Boosts", value: "3", inline: true }, - { name: "Member", value: interaction.user.tag, inline: true } - ) - .setTimestamp(); - - await interaction.followUp({ - content: "**[1/6] Greet channel — boost start announcement:**", - embeds: [greetEmbed], - }); - - // 2. Boost start log embed - const logStartEmbed = new EmbedBuilder() - .setColor(0x57f287) - .setTitle("Boost Started") - .addFields( - { name: "User", value: `${interaction.user.tag} (${interaction.user.id})`, inline: false }, - { name: "Total Boost Count", value: "3", inline: true } - ) - .setTimestamp(); - - await interaction.followUp({ - content: "**[2/6] Log channel — boost started:**", - embeds: [logStartEmbed], - }); - - // 3. Boost end log embed - const logEndEmbed = new EmbedBuilder() - .setColor(0xed4245) - .setTitle("Boost Ended") - .addFields( - { name: "User", value: `${interaction.user.tag} (${interaction.user.id})`, inline: false }, - { name: "Historical Boost Count", value: "3", inline: true } - ) - .setTimestamp(); - - await interaction.followUp({ - content: "**[3/6] Log channel — boost ended:**", - embeds: [logEndEmbed], - }); - - // 4. /booster check embed - const checkEmbed = new EmbedBuilder() - .setColor(0xf47fff) - .setTitle(`Booster Info: ${interaction.user.username}`) - .addFields( - { name: "Status", value: "Active", inline: true }, - { name: "Boost Count", value: "3", inline: true }, - { name: "Custom Role", value: "@MyCustomRole", inline: true }, - { name: "Private Channel", value: "#boost-channel", inline: true }, - { name: "First Boosted", value: new Date().toLocaleDateString(), inline: true }, - { name: "Last Updated", value: new Date().toLocaleDateString(), inline: true } - ) - .setTimestamp(); - - await interaction.followUp({ - content: "**[4/6] /booster check response:**", - embeds: [checkEmbed], - }); - - // 5. /booster stats embed - const statsEmbed = new EmbedBuilder() - .setColor(0xf47fff) - .setTitle("Server Boost Statistics") - .addFields( - { name: "Current Boosters", value: "12", inline: true }, - { name: "Total Boosts (All Time)", value: "47", inline: true }, - { name: "Unique Boosters (All Time)", value: "19", inline: true } - ) - .setTimestamp(); - - await interaction.followUp({ - content: "**[5/6] /booster stats response:**", - embeds: [statsEmbed], - }); - - // 6. DM preview - await interaction.followUp({ - content: - "**[6/6] DM sent to booster on boost start:**\n> Thank you for boosting the server! You now have access to booster perks.", - }); - }, -}) \ No newline at end of file diff --git a/src/commands/settings.ts b/src/commands/settings.ts index e69de29..9b4a7a3 100644 --- a/src/commands/settings.ts +++ b/src/commands/settings.ts @@ -0,0 +1,40 @@ +import { + SlashCommandBuilder, + ModalBuilder, + ChannelType, + LabelBuilder, +} from "discord.js"; +import { Command } from "../base/classes/command.js"; + +export default new Command({ + info: new SlashCommandBuilder() + .setName("config") + .setDescription("Change the configuration of this server."), + async execute(interaction) { + if (!interaction.guild) return; + + const modal = new ModalBuilder().setTitle('Configuration').setCustomId('configboostifymodal') + const GreetingChannelRes = new LabelBuilder() + .setLabel('Where should boosts be sent?') + .setChannelSelectMenuComponent( + (channel) => + channel.addChannelTypes(ChannelType.GuildAnnouncement, ChannelType.GuildText) + .setCustomId('boostchannel') + .setRequired(true) + ); + + const LoggingChannel = new LabelBuilder() + .setLabel('Where should logs be sent?') + .setChannelSelectMenuComponent( + (channel) => + channel.addChannelTypes(ChannelType.GuildText) + .setCustomId('logs') + .setRequired(true) + ); + + modal.addLabelComponents(GreetingChannelRes, LoggingChannel); + interaction.showModal(modal); + }, + ownerOnly: true, +}) + diff --git a/src/events/setupResponse.ts b/src/events/setupResponse.ts index a554040..3c820ca 100644 --- a/src/events/setupResponse.ts +++ b/src/events/setupResponse.ts @@ -1,21 +1,25 @@ import { ChannelType, Client, + ContainerBuilder, Events, Interaction, MessageFlags } from "discord.js"; import { prisma } from "../libs/database.js"; +import { SystemColors } from "../libs/colors.js"; export default { name: Events.InteractionCreate, async execute(_client: Client, interaction: Interaction) { if (!interaction.isModalSubmit()) return; if (!interaction.guild) return; - if (interaction.customId != 'setupboostifymodal') return; + if (interaction.customId != 'setupboostifymodal' && interaction.customId != 'configboostifymodal') return; const boostchannel = interaction.fields.getSelectedChannels('boostchannel', true, [ChannelType.GuildText, ChannelType.GuildAnnouncement]); const logsChannel = interaction.fields.getSelectedChannels('logs', true, [ChannelType.GuildText]); + const setup = await prisma.guildSetting.findFirst({ where: { gid: interaction.guild.id }}) + const boostChannelId = boostchannel.first() const logChannelId = logsChannel.first() @@ -23,18 +27,34 @@ export default { return interaction.reply({ content: 'Please select both channels.', ephemeral: true }); } - await prisma.guildSetting.create({ - data: { + await prisma.guildSetting.upsert({ + where: { + gid: interaction.guild.id + }, + update: { + greetChannelId: boostChannelId.id, + logChannelId: logChannelId.id + }, + create: { uid: crypto.randomUUID(), - gid: interaction.guild!.id, + gid: interaction.guild.id, greetChannelId: boostChannelId.id, - logChannelId: logChannelId.id, + logChannelId: logChannelId.id } }); + const container = new ContainerBuilder() + .setAccentColor(SystemColors.main) + .addTextDisplayComponents( + (txt) => txt.setContent([ + `## ${!setup ? "Aaannndd... we're done!" : "Configuration changed" }`, + `- Boost notifications: ${boostChannelId}\n- Logs: ${logChannelId}` + ].join('\n')) + ); + await interaction.reply({ - content: `Setup complete!\n- Boost notifications: ${boostChannelId}\n- Logs: ${logChannelId}`, - flags: MessageFlags.Ephemeral, - }); + components: [container], + flags: [MessageFlags.Ephemeral, MessageFlags.IsComponentsV2] + }) } }; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 102d4cd..bdc3ff7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,12 +70,12 @@ client.commands = new Collection(); const commandsPath = path.join(__dirname, "commands"); const commandFiles = fs .readdirSync(commandsPath) - .filter((file) => file.endsWith(".js") || file.endsWith(".ts")); + .filter((file) => file.endsWith(".js") || file.endsWith(".ts") || !file.endsWith(".map")); const eventsPath = path.join(__dirname, "events"); const eventFiles = fs .readdirSync(eventsPath) - .filter((file) => file.endsWith(".js") || file.endsWith(".ts")); + .filter((file) => file.endsWith(".js") || file.endsWith(".ts") || !file.endsWith(".map")); (async () => { for (const file of commandFiles) { diff --git a/src/libs/loadCommands.ts b/src/libs/loadCommands.ts index 9d1a449..22c4801 100644 --- a/src/libs/loadCommands.ts +++ b/src/libs/loadCommands.ts @@ -35,7 +35,7 @@ export async function loadCommands(): Promise { const commandFiles = fs .readdirSync(commandsPath) - .filter((file) => file.endsWith(".ts") || !file.endsWith("test.ts") ||file.endsWith(".js") || !file.endsWith("test.js")); + .filter((file) => file.endsWith(".ts") ||file.endsWith(".js")); if (commandFiles.length === 0) { logger.warn("No command files found — nothing to register."); diff --git a/tsconfig.json b/tsconfig.json index 0486d3a..650cc83 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,5 +15,5 @@ "sourceMap": true }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "exclude": ["**/*.map", "node_modules", "dist"] } \ No newline at end of file