diff --git a/src/buttons/dailyTasks/autoPin.ts b/src/buttons/dailyTasks/autoPin.ts index bd6e5b62..2e7ce318 100644 --- a/src/buttons/dailyTasks/autoPin.ts +++ b/src/buttons/dailyTasks/autoPin.ts @@ -24,32 +24,32 @@ const button: Button = { const check = guildDb.autoPin; const autoPin = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${check ? ":x:" : ":white_check_mark:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -61,11 +61,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -73,11 +73,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -85,8 +85,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -95,10 +95,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -108,11 +108,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -120,11 +120,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -132,10 +132,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -145,20 +145,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Secondary : ButtonStyle.Success + guildDb.autoPin ? ButtonStyle.Secondary : ButtonStyle.Success, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -166,12 +169,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/dailyTasks/dailyDeleteRole.ts b/src/buttons/dailyTasks/dailyDeleteRole.ts index 8ad5e9d0..4afee429 100644 --- a/src/buttons/dailyTasks/dailyDeleteRole.ts +++ b/src/buttons/dailyTasks/dailyDeleteRole.ts @@ -13,12 +13,12 @@ const button: Button = { execute: async (interaction, client, guildDb) => { const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyRole")}: :x:\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + @@ -26,16 +26,16 @@ const button: Button = { `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -47,11 +47,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -59,8 +59,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle(ButtonStyle.Secondary), new ButtonBuilder() @@ -69,8 +69,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -79,10 +79,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -92,11 +92,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -104,11 +104,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -116,10 +116,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -129,20 +129,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -150,12 +153,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/dailyTasks/dailyInterval.ts b/src/buttons/dailyTasks/dailyInterval.ts index 9117641f..f259ae64 100644 --- a/src/buttons/dailyTasks/dailyInterval.ts +++ b/src/buttons/dailyTasks/dailyInterval.ts @@ -10,7 +10,7 @@ import { Modal, type ModalData } from "../../util/modalHandler"; function isFormat(str: string) { return /^(?:[01]\d|2[0-4]):(?:00|05|10|15|20|25|30|35|40|45|50|55)$/.test( - str + str, ); } @@ -39,7 +39,7 @@ const button: Button = { ephemeral: true, content: client.translation.get( guildDb?.language, - "Settings.intervalSame" + "Settings.intervalSame", ), }); return; @@ -49,39 +49,39 @@ const button: Button = { ephemeral: true, content: client.translation.get( guildDb?.language, - "Settings.intervalInvalid" + "Settings.intervalInvalid", ), }); return; } const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${value}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -93,11 +93,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -105,11 +105,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -117,8 +117,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -127,10 +127,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -140,11 +140,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -152,11 +152,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -164,10 +164,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -177,20 +177,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -198,12 +201,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/dailyTasks/dailyMsg.ts b/src/buttons/dailyTasks/dailyMsg.ts index 3ae5e33a..648523d4 100644 --- a/src/buttons/dailyTasks/dailyMsg.ts +++ b/src/buttons/dailyTasks/dailyMsg.ts @@ -14,32 +14,32 @@ const button: Button = { const check = guildDb.dailyMsg; const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${check ? ":x:" : ":white_check_mark:"}` + "Settings.embed.dailyMsg", + )}: ${check ? ":x:" : ":white_check_mark:"}`, ) .setColor("#0598F6"); @@ -51,11 +51,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -63,11 +63,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -75,8 +75,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -85,10 +85,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -98,11 +98,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -110,11 +110,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -122,10 +122,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -135,20 +135,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -156,10 +159,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) - .setStyle(check ? ButtonStyle.Secondary : ButtonStyle.Success) + .setStyle(check ? ButtonStyle.Secondary : ButtonStyle.Success), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/dailyTasks/dailyQuestionType.ts b/src/buttons/dailyTasks/dailyQuestionType.ts index 329aba54..1adfc8b9 100644 --- a/src/buttons/dailyTasks/dailyQuestionType.ts +++ b/src/buttons/dailyTasks/dailyQuestionType.ts @@ -41,15 +41,15 @@ const button: Button = { new StringSelectMenuOptionBuilder() .setLabel(`Topics`) .setDefault(guildDb.dailyQuestionType.includes("topicModel")) - .setValue("topicModel") - ) + .setValue("topicModel"), + ), ); interaction.update({ embeds: [], content: client.translation.get( guildDb?.language, - "Settings.dailyQuestionType" + "Settings.dailyQuestionType", ), components: [inter], options: { diff --git a/src/buttons/dailyTasks/dailyThread.ts b/src/buttons/dailyTasks/dailyThread.ts index ae78c878..893d2d0a 100644 --- a/src/buttons/dailyTasks/dailyThread.ts +++ b/src/buttons/dailyTasks/dailyThread.ts @@ -14,32 +14,32 @@ const button: Button = { const check = guildDb.dailyThread; const dailyThreads = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${check ? ":x:" : ":white_check_mark:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -51,11 +51,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -63,11 +63,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -75,8 +75,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -85,10 +85,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -98,11 +98,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -110,11 +110,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -122,10 +122,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -135,18 +135,21 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle(check ? ButtonStyle.Secondary : ButtonStyle.Success), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -154,12 +157,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/dailyTasks/dailyTimezone.ts b/src/buttons/dailyTasks/dailyTimezone.ts index b44c3335..8c5c5446 100644 --- a/src/buttons/dailyTasks/dailyTimezone.ts +++ b/src/buttons/dailyTasks/dailyTimezone.ts @@ -54,7 +54,7 @@ const button: Button = { ephemeral: true, content: client.translation.get( guildDb?.language, - "Settings.errorSame" + "Settings.errorSame", ), }); return; @@ -65,7 +65,7 @@ const button: Button = { ephemeral: true, content: client.translation.get( guildDb?.language, - "Settings.errorInvalid" + "Settings.errorInvalid", ), }); return; @@ -76,7 +76,7 @@ const button: Button = { ephemeral: true, content: client.translation.get( guildDb?.language, - "Settings.errorInvalid" + "Settings.errorInvalid", ), }); return; @@ -84,32 +84,32 @@ const button: Button = { const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${value}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -121,11 +121,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -133,11 +133,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -145,8 +145,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -155,10 +155,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -168,11 +168,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -180,11 +180,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -192,10 +192,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -205,20 +205,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -226,12 +229,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/gamesActivities/higherlower.ts b/src/buttons/gamesActivities/higherlower.ts index 5336b4ef..13a33504 100644 --- a/src/buttons/gamesActivities/higherlower.ts +++ b/src/buttons/gamesActivities/higherlower.ts @@ -125,8 +125,8 @@ const button: Button = { source2: game.items.history[game.items.history.length - 1].link || "https://wouldyoubot.gg/nolink", - } - )}` + }, + )}`, ) .setColor("White") .setImage("attachment://game.png") @@ -146,7 +146,7 @@ const button: Button = { new ButtonBuilder() .setCustomId(`lower_${game.id}`) .setLabel("Lower") - .setStyle(ButtonStyle.Danger) + .setStyle(ButtonStyle.Danger), ); interaction diff --git a/src/buttons/miscellaneous/deleteCustomPerm.ts b/src/buttons/miscellaneous/deleteCustomPerm.ts new file mode 100644 index 00000000..b2b6578f --- /dev/null +++ b/src/buttons/miscellaneous/deleteCustomPerm.ts @@ -0,0 +1,108 @@ +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + EmbedBuilder, + type MessageActionRowComponentBuilder, +} from "discord.js"; +import type { Button } from "../../interfaces"; + +const button: Button = { + name: "deleteCustomPerm", + cooldown: false, + execute: async (interaction, client, guildDb) => { + const emb = new EmbedBuilder() + .setTitle( + client.translation.get( + guildDb?.language, + "Settings.embed.utilityTitle", + ), + ) + .setDescription( + `${client.translation.get( + guildDb?.language, + "Settings.embed.customPerm", + )}: :x:\n${client.translation.get( + guildDb?.language, + "Settings.embed.username", + )}: ${guildDb.webhookName ? guildDb.webhookName : ":x:"}\n${client.translation.get( + guildDb?.language, + "Settings.embed.avatar", + )}: ${guildDb.webhookAvatar ? `[Image](<${guildDb.webhookAvatar}>)` : ":x:"}\n${client.translation.get( + guildDb?.language, + "Settings.embed.classicMode", + )}: ${guildDb.classicMode ? ":x:" : ":white_check_mark:"}`, + ) + .setColor("#0598F6") + .setFooter({ + text: client.translation.get( + guildDb?.language, + "Settings.embed.footer", + ), + iconURL: client?.user?.displayAvatarURL() || undefined, + }); + + const button = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("webhookName") + .setEmoji("1185973660465500180") + .setLabel( + client.translation.get(guildDb?.language, "Settings.button.name"), + ) + .setStyle(ButtonStyle.Success), + new ButtonBuilder() + .setCustomId("webhookAvatar") + .setEmoji("1207801424503644260") + .setLabel( + client.translation.get(guildDb?.language, "Settings.button.avatar"), + ) + .setStyle( + guildDb.webhookAvatar ? ButtonStyle.Success : ButtonStyle.Secondary, + ), + ); + + const button2 = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("classicMode") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.classicMode", + ), + ) + .setStyle( + guildDb.classicMode ? ButtonStyle.Secondary : ButtonStyle.Success, + ), + new ButtonBuilder() + .setCustomId("customPerm") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.customPerm", + ), + ) + .setStyle(ButtonStyle.Secondary), + ); + + await client.database.updateGuild(interaction.guild?.id || "", { + ...guildDb, + customPerm: null, + }); + + interaction.update({ + content: null, + embeds: [emb], + components: [button, button2], + options: { + ephemeral: true, + }, + }); + return; + }, +}; + +export default button; diff --git a/src/buttons/premium/webhookAvatar.ts b/src/buttons/premium/webhookAvatar.ts index 6116ce71..c8b9da08 100644 --- a/src/buttons/premium/webhookAvatar.ts +++ b/src/buttons/premium/webhookAvatar.ts @@ -63,6 +63,9 @@ const button: Button = { ) .setDescription( `${client.translation.get( + guildDb?.language, + "Settings.embed.customPerm", + )}: ${guildDb.customPerm ? `<@&${guildDb.customPerm}>` : ":x:"}\n${client.translation.get( guildDb?.language, "Settings.embed.username", )}: ${guildDb.webhookName ? guildDb.webhookName : ":x:"}\n${client.translation.get( @@ -116,6 +119,18 @@ const button: Button = { .setStyle( guildDb.classicMode ? ButtonStyle.Success : ButtonStyle.Secondary, ), + new ButtonBuilder() + .setCustomId("customPerm") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.customPerm", + ), + ) + .setStyle( + guildDb.customPerm ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); async function getImageData() { diff --git a/src/buttons/premium/webhookName.ts b/src/buttons/premium/webhookName.ts index f32593b8..05d4a173 100644 --- a/src/buttons/premium/webhookName.ts +++ b/src/buttons/premium/webhookName.ts @@ -64,7 +64,10 @@ const button: Button = { ), ) .setDescription( - `${client.translation.get(guildDb?.language, "Settings.embed.username")}: ${value}\n${client.translation.get( + `${client.translation.get( + guildDb?.language, + "Settings.embed.customPerm", + )}: ${guildDb.customPerm ? `<@&${guildDb.customPerm}>` : ":x:"}\n${client.translation.get(guildDb?.language, "Settings.embed.username")}: ${value}\n${client.translation.get( guildDb?.language, "Settings.embed.avatar", )}: ${guildDb.webhookAvatar ? `[Image](<${guildDb.webhookAvatar}>)` : ":x:"}\n${client.translation.get( @@ -115,6 +118,18 @@ const button: Button = { .setStyle( guildDb.classicMode ? ButtonStyle.Success : ButtonStyle.Secondary, ), + new ButtonBuilder() + .setCustomId("customPerm") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.customPerm", + ), + ) + .setStyle( + guildDb.customPerm ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/selectionMenus/selectMenuChannel.ts b/src/buttons/selectionMenus/selectMenuChannel.ts index e8147ffd..366facde 100644 --- a/src/buttons/selectionMenus/selectMenuChannel.ts +++ b/src/buttons/selectionMenus/selectMenuChannel.ts @@ -14,29 +14,29 @@ const button: Button = { const newChannel = (interaction as any).values[0]; const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get(guildDb?.language, "Settings.embed.dailyChannel")}: <#${newChannel}>\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -48,11 +48,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -60,11 +60,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -72,8 +72,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -82,10 +82,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -95,11 +95,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -107,11 +107,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -119,10 +119,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -132,20 +132,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -153,12 +156,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/selectionMenus/selectMenuCustomRole.ts b/src/buttons/selectionMenus/selectMenuCustomRole.ts new file mode 100644 index 00000000..8a0a846e --- /dev/null +++ b/src/buttons/selectionMenus/selectMenuCustomRole.ts @@ -0,0 +1,109 @@ +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + EmbedBuilder, + type MessageActionRowComponentBuilder, +} from "discord.js"; +import type { Button } from "../../interfaces"; + +const button: Button = { + name: "selectMenuCustomRole", + cooldown: false, + execute: async (interaction: any, client, guildDb) => { + const newRole = interaction.values[0]; + const emb = new EmbedBuilder() + .setTitle( + client.translation.get( + guildDb?.language, + "Settings.embed.utilityTitle", + ), + ) + .setDescription( + `${client.translation.get( + guildDb?.language, + "Settings.embed.customPerm", + )}: <@&${newRole}>\n${client.translation.get( + guildDb?.language, + "Settings.embed.username", + )}: ${guildDb.webhookName ? guildDb.webhookName : ":x:"}\n${client.translation.get( + guildDb?.language, + "Settings.embed.avatar", + )}: ${guildDb.webhookAvatar ? `[Image](<${guildDb.webhookAvatar}>)` : ":x:"}\n${client.translation.get( + guildDb?.language, + "Settings.embed.classicMode", + )}: ${guildDb.classicMode ? ":x:" : ":white_check_mark:"}`, + ) + .setColor("#0598F6") + .setFooter({ + text: client.translation.get( + guildDb?.language, + "Settings.embed.footer", + ), + iconURL: client?.user?.displayAvatarURL() || undefined, + }); + + const button = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("webhookName") + .setEmoji("1185973660465500180") + .setLabel( + client.translation.get(guildDb?.language, "Settings.button.name"), + ) + .setStyle(ButtonStyle.Success), + new ButtonBuilder() + .setCustomId("webhookAvatar") + .setEmoji("1207801424503644260") + .setLabel( + client.translation.get(guildDb?.language, "Settings.button.avatar"), + ) + .setStyle( + guildDb.webhookAvatar ? ButtonStyle.Success : ButtonStyle.Secondary, + ), + ); + + const button2 = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("classicMode") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.classicMode", + ), + ) + .setStyle( + guildDb.classicMode ? ButtonStyle.Secondary : ButtonStyle.Success, + ), + new ButtonBuilder() + .setCustomId("customPerm") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.customPerm", + ), + ) + .setStyle(ButtonStyle.Success), + ); + + await client.database.updateGuild(interaction.guild?.id || "", { + ...guildDb, + customPerm: newRole, + }); + + interaction.update({ + content: null, + embeds: [emb], + components: [button, button2], + options: { + ephemeral: true, + }, + }); + return; + }, +}; + +export default button; diff --git a/src/buttons/selectionMenus/selectMenuDays.ts b/src/buttons/selectionMenus/selectMenuDays.ts index 7f7e9c20..c4564ad3 100644 --- a/src/buttons/selectionMenus/selectMenuDays.ts +++ b/src/buttons/selectionMenus/selectMenuDays.ts @@ -15,32 +15,32 @@ const button: Button = { const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -52,11 +52,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -64,8 +64,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -74,8 +74,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -84,10 +84,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -97,11 +97,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -109,11 +109,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -121,10 +121,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -134,20 +134,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -155,12 +158,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild.id, { ...guildDb, diff --git a/src/buttons/selectionMenus/selectMenuQuestionType.ts b/src/buttons/selectionMenus/selectMenuQuestionType.ts index 424c80b2..c447783d 100644 --- a/src/buttons/selectionMenus/selectMenuQuestionType.ts +++ b/src/buttons/selectionMenus/selectMenuQuestionType.ts @@ -14,32 +14,32 @@ const button: Button = { const newType = interaction.values; const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -51,11 +51,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -63,11 +63,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -75,8 +75,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -85,10 +85,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -98,11 +98,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -110,11 +110,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -122,10 +122,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -135,20 +135,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -156,12 +159,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild.id, { diff --git a/src/buttons/selectionMenus/selectMenuRole.ts b/src/buttons/selectionMenus/selectMenuRole.ts index 3ff3d951..3e08c2c0 100644 --- a/src/buttons/selectionMenus/selectMenuRole.ts +++ b/src/buttons/selectionMenus/selectMenuRole.ts @@ -14,12 +14,12 @@ const button: Button = { const newRole = interaction.values[0]; const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyRole")}: <@&${newRole}>\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + @@ -27,16 +27,16 @@ const button: Button = { `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -48,11 +48,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -60,8 +60,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -70,8 +70,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -80,10 +80,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -93,11 +93,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -105,11 +105,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -117,10 +117,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -130,20 +130,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -151,12 +154,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild.id, { diff --git a/src/buttons/selectionMenus/selectMenuType.ts b/src/buttons/selectionMenus/selectMenuType.ts index 0b3028b9..af9be70c 100644 --- a/src/buttons/selectionMenus/selectMenuType.ts +++ b/src/buttons/selectionMenus/selectMenuType.ts @@ -14,32 +14,32 @@ const button: Button = { const newType = interaction.values[0]; const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${newType}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -51,11 +51,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") @@ -63,11 +63,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyRole" - ) + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") @@ -75,8 +75,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -85,10 +85,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); const dailyButtons2 = new ActionRowBuilder().addComponents( @@ -98,11 +98,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -110,11 +110,11 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") @@ -122,10 +122,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.daySelect" - ) + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); const dailyButtons3 = new ActionRowBuilder().addComponents( @@ -135,20 +135,23 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get( + guildDb?.language, + "Settings.button.autoPin", + ), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") @@ -156,12 +159,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyMsg" - ) + "Settings.button.dailyMsg", + ), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild.id, { diff --git a/src/buttons/selectionMenus/selectMenuWelcome.ts b/src/buttons/selectionMenus/selectMenuWelcome.ts index 094a3310..cbff33d5 100644 --- a/src/buttons/selectionMenus/selectMenuWelcome.ts +++ b/src/buttons/selectionMenus/selectMenuWelcome.ts @@ -23,35 +23,38 @@ const button: Button = { const welcomes = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") + client.translation.get( + guildDb?.language, + "Settings.embed.welcomeTitle", + ), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.welcome" + "Settings.embed.welcome", )}: ${guildDb.welcome ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomePing" + "Settings.embed.welcomePing", )}: ${guildDb.welcomePing ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.dailyType" + "Settings.embed.dailyType", )}: ${guildDb.welcomeType}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeChannel" + "Settings.embed.welcomeChannel", )}: <#${newChannel}>\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeMessage" + "Settings.embed.welcomeMessage", )}: ${ guildDb.welcomeMessage ? truncateString(guildDb.welcomeMessage, 100) : ":x:" - }` + }`, ) .setColor("#0598F6") .setFooter({ text: client.translation.get( guildDb?.language, - "Settings.embed.footer" + "Settings.embed.footer", ), iconURL: client?.user?.displayAvatarURL() || undefined, }); @@ -64,8 +67,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary) .setEmoji("1185973667973320775"), @@ -75,25 +78,27 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeChannel" - ) + "Settings.button.welcomeChannel", + ), ) .setStyle( - guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeChannel + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeTest") .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeTest" - ) + "Settings.button.welcomeTest", + ), ) .setDisabled(guildDb.welcome ? false : true) .setStyle( - guildDb.welcome ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcome ? ButtonStyle.Primary : ButtonStyle.Secondary, ) - .setEmoji("1207800685928910909") + .setEmoji("1207800685928910909"), ); const welcomeButtons2 = new ActionRowBuilder().addComponents( @@ -101,10 +106,13 @@ const button: Button = { .setCustomId("welcome") .setEmoji("1185973660465500180") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.welcome") + client.translation.get( + guildDb?.language, + "Settings.button.welcome", + ), ) .setStyle( - guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomePing") @@ -112,12 +120,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomePing" - ) + "Settings.button.welcomePing", + ), ) .setStyle( - guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); const welcomeButtons3 = @@ -128,11 +136,13 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeMessage" - ) + "Settings.button.welcomeMessage", + ), ) .setStyle( - guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeMessage + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeEmbedEdit") @@ -140,10 +150,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedEdit" - ) + "Settings.button.welcomeEmbedEdit", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); await client.database.updateGuild(interaction.guild.id, { diff --git a/src/buttons/selectionMenus/selectMenuWelcomeEmbed.ts b/src/buttons/selectionMenus/selectMenuWelcomeEmbed.ts index f4aab292..ef33ab13 100644 --- a/src/buttons/selectionMenus/selectMenuWelcomeEmbed.ts +++ b/src/buttons/selectionMenus/selectMenuWelcomeEmbed.ts @@ -70,7 +70,7 @@ const button: Button = { guildDb: guildDb, [interaction.values[0]]: ButtonStyle.Secondary, }); - const welcomeButtons5 = SelectMenu(client, guildDb); + const welcomeButtons5 = SelectMenu(client, guildDb); await client.database.updateGuild(interaction.guild?.id || "", { ...guildDb, diff --git a/src/buttons/selectionMenus/selectMenuWelcomeType.ts b/src/buttons/selectionMenus/selectMenuWelcomeType.ts index 7e8ca61c..9c66ee71 100644 --- a/src/buttons/selectionMenus/selectMenuWelcomeType.ts +++ b/src/buttons/selectionMenus/selectMenuWelcomeType.ts @@ -23,35 +23,38 @@ const button: Button = { const dailyMsgs = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") + client.translation.get( + guildDb?.language, + "Settings.embed.welcomeTitle", + ), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.welcome" + "Settings.embed.welcome", )}: ${guildDb.welcome ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomePing" + "Settings.embed.welcomePing", )}: ${guildDb.welcomePing ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.dailyType" + "Settings.embed.dailyType", )}: ${newType}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeChannel" + "Settings.embed.welcomeChannel", )}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeMessage" + "Settings.embed.welcomeMessage", )}: ${ guildDb.welcomeMessage ? truncateString(guildDb.welcomeMessage, 100) : ":x:" - }` + }`, ) .setColor("#0598F6") .setFooter({ text: client.translation.get( guildDb?.language, - "Settings.embed.footer" + "Settings.embed.footer", ), iconURL: client?.user?.displayAvatarURL() || undefined, }); @@ -64,8 +67,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary) .setEmoji("1185973667973320775"), @@ -75,29 +78,31 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeChannel" - ) + "Settings.button.welcomeChannel", + ), ) .setStyle( - guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeChannel + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeTest") .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeTest" - ) + "Settings.button.welcomeTest", + ), ) .setDisabled( - guildDb.welcomeChannel && guildDb?.welcome ? false : true + guildDb.welcomeChannel && guildDb?.welcome ? false : true, ) .setStyle( guildDb.welcomeChannel && guildDb?.welcome ? ButtonStyle.Primary - : ButtonStyle.Secondary + : ButtonStyle.Secondary, ) - .setEmoji("1207800685928910909") + .setEmoji("1207800685928910909"), ); const welcomeButtons2 = new ActionRowBuilder().addComponents( @@ -105,10 +110,13 @@ const button: Button = { .setCustomId("welcome") .setEmoji("1185973660465500180") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.welcome") + client.translation.get( + guildDb?.language, + "Settings.button.welcome", + ), ) .setStyle( - guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomePing") @@ -116,14 +124,14 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomePing" - ) + "Settings.button.welcomePing", + ), ) .setStyle( - guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); - + const welcomeButtons3 = new ActionRowBuilder().addComponents( new ButtonBuilder() @@ -132,11 +140,13 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeMessage" - ) + "Settings.button.welcomeMessage", + ), ) .setStyle( - guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeMessage + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeEmbedEdit") @@ -144,10 +154,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedEdit" - ) + "Settings.button.welcomeEmbedEdit", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); await client.database.updateGuild(interaction.guild.id, { diff --git a/src/buttons/utilityInformation/classicMode.ts b/src/buttons/utilityInformation/classicMode.ts index 80540b5d..70d0a27c 100644 --- a/src/buttons/utilityInformation/classicMode.ts +++ b/src/buttons/utilityInformation/classicMode.ts @@ -21,6 +21,9 @@ const button: Button = { ) .setDescription( `${client.translation.get( + guildDb?.language, + "Settings.embed.customPerm", + )}: ${guildDb.customPerm ? `<@&${guildDb.customPerm}>` : ":x:"}\n${client.translation.get( guildDb?.language, "Settings.embed.username", )}: ${guildDb.webhookName ? guildDb.webhookName : ":x:"}\n${client.translation.get( @@ -72,6 +75,18 @@ const button: Button = { ), ) .setStyle(check ? ButtonStyle.Secondary : ButtonStyle.Success), + new ButtonBuilder() + .setCustomId("customPerm") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.customPerm", + ), + ) + .setStyle( + guildDb.customPerm ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/utilityInformation/customPerm.ts b/src/buttons/utilityInformation/customPerm.ts new file mode 100644 index 00000000..58bd6926 --- /dev/null +++ b/src/buttons/utilityInformation/customPerm.ts @@ -0,0 +1,40 @@ +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + type MessageActionRowComponentBuilder, + RoleSelectMenuBuilder, +} from "discord.js"; +import type { Button } from "../../interfaces"; + +const button: Button = { + name: "customPerm", + cooldown: false, + execute: async (interaction, client, guildDb) => { + const inter = + new ActionRowBuilder().addComponents( + new RoleSelectMenuBuilder() + .setCustomId("selectMenuCustomRole") + .setPlaceholder("Select a role that can add custom messages."), + ); + + const inter2 = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("deleteCustomPerm") + .setLabel("Delete Custom Permission Role") + .setStyle(ButtonStyle.Danger), + ); + + interaction.update({ + embeds: [], + content: client.translation.get(guildDb?.language, "Settings.customPerm"), + components: guildDb?.customPerm ? [inter, inter2] : [inter], + options: { + ephemeral: true, + }, + }); + }, +}; + +export default button; diff --git a/src/buttons/utilityInformation/voting.ts b/src/buttons/utilityInformation/voting.ts index 13b7b209..eb2593a4 100644 --- a/src/buttons/utilityInformation/voting.ts +++ b/src/buttons/utilityInformation/voting.ts @@ -1,4 +1,9 @@ -import { ActionRowBuilder, AnyComponentBuilder, ButtonBuilder, ButtonComponentData } from "discord.js"; +import { + ActionRowBuilder, + AnyComponentBuilder, + ButtonBuilder, + ButtonComponentData, +} from "discord.js"; import type { Button } from "../../interfaces"; const button: Button = { @@ -33,21 +38,25 @@ const button: Button = { } else { replyContent; } - const unchangedRow = ActionRowBuilder.from(interaction.message.components[1]) - const updatedResult = ActionRowBuilder.from(interaction.message.components[0]) - + const unchangedRow = ActionRowBuilder.from( + interaction.message.components[1], + ); + const updatedResult = ActionRowBuilder.from( + interaction.message.components[0], + ); + const resultButton = updatedResult.components[0] as ButtonBuilder; resultButton.setDisabled(false); // @ts-expect-error no clue why it complains but it works! await interaction.update({ - components: [updatedResult, unchangedRow] - }) + components: [updatedResult, unchangedRow], + }); - interaction.followUp({ - content: replyContent, - ephemeral: true, - }); + interaction.followUp({ + content: replyContent, + ephemeral: true, + }); }, }; diff --git a/src/buttons/welcomeMessages/welcome.ts b/src/buttons/welcomeMessages/welcome.ts index 3854763f..9f6d2e30 100644 --- a/src/buttons/welcomeMessages/welcome.ts +++ b/src/buttons/welcomeMessages/welcome.ts @@ -23,35 +23,38 @@ const button: Button = { const welcomes = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") + client.translation.get( + guildDb?.language, + "Settings.embed.welcomeTitle", + ), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.welcome" + "Settings.embed.welcome", )}: ${check ? ":x:" : ":white_check_mark:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomePing" + "Settings.embed.welcomePing", )}: ${guildDb.welcomePing ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.dailyType" + "Settings.embed.dailyType", )}: ${guildDb.welcomeType}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeChannel" + "Settings.embed.welcomeChannel", )}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeMessage" + "Settings.embed.welcomeMessage", )}: ${ guildDb.welcomeMessage ? truncateString(guildDb.welcomeMessage, 100) : ":x:" - }` + }`, ) .setColor("#0598F6") .setFooter({ text: client.translation.get( guildDb?.language, - "Settings.embed.footer" + "Settings.embed.footer", ), iconURL: client?.user?.displayAvatarURL() || undefined, }); @@ -64,8 +67,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary) .setEmoji("1185973667973320775"), @@ -75,29 +78,31 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeChannel" - ) + "Settings.button.welcomeChannel", + ), ) .setStyle( - guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeChannel + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeTest") .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeTest" - ) + "Settings.button.welcomeTest", + ), ) .setDisabled( - guildDb.welcomeChannel && guildDb?.welcome ? true : false + guildDb.welcomeChannel && guildDb?.welcome ? true : false, ) .setStyle( guildDb.welcomeChannel && guildDb?.welcome ? ButtonStyle.Secondary - : ButtonStyle.Primary + : ButtonStyle.Primary, ) - .setEmoji("1207800685928910909") + .setEmoji("1207800685928910909"), ); const welcomeButtons2 = new ActionRowBuilder().addComponents( @@ -105,7 +110,10 @@ const button: Button = { .setCustomId("welcome") .setEmoji("1185973660465500180") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.welcome") + client.translation.get( + guildDb?.language, + "Settings.button.welcome", + ), ) .setStyle(check ? ButtonStyle.Secondary : ButtonStyle.Success), new ButtonBuilder() @@ -114,12 +122,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomePing" - ) + "Settings.button.welcomePing", + ), ) .setStyle( - guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); const welcomeButtons3 = @@ -130,11 +138,13 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeMessage" - ) + "Settings.button.welcomeMessage", + ), ) .setStyle( - guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeMessage + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeEmbedEdit") @@ -142,10 +152,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedEdit" - ) + "Settings.button.welcomeEmbedEdit", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbed.ts b/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbed.ts index 268592bb..ab12e07c 100644 --- a/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbed.ts +++ b/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbed.ts @@ -19,35 +19,38 @@ const button: Button = { const welcomeEmbed = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") + client.translation.get( + guildDb?.language, + "Settings.embed.welcomeTitle", + ), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.welcome" + "Settings.embed.welcome", )}: ${guildDb.welcome ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomePing" + "Settings.embed.welcomePing", )}: ${guildDb.welcomePing ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.dailyType" + "Settings.embed.dailyType", )}: ${guildDb.welcomeType}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeChannel" + "Settings.embed.welcomeChannel", )}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeMessage" + "Settings.embed.welcomeMessage", )}: ${ guildDb.welcomeMessage ? truncateString(guildDb.welcomeMessage, 100) : ":x:" - }` + }`, ) .setColor("#0598F6") .setFooter({ text: client.translation.get( guildDb?.language, - "Settings.embed.footer" + "Settings.embed.footer", ), iconURL: client?.user?.displayAvatarURL() || undefined, }); @@ -60,8 +63,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -70,29 +73,31 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeChannel" - ) + "Settings.button.welcomeChannel", + ), ) .setStyle( - guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeChannel + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeTest") .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeTest" - ) + "Settings.button.welcomeTest", + ), ) .setDisabled( - guildDb.welcomeChannel && guildDb?.welcome ? false : true + guildDb.welcomeChannel && guildDb?.welcome ? false : true, ) .setStyle( guildDb.welcomeChannel && guildDb?.welcome ? ButtonStyle.Primary - : ButtonStyle.Secondary + : ButtonStyle.Secondary, ) - .setEmoji("1207800685928910909") + .setEmoji("1207800685928910909"), ); // Second button row @@ -103,10 +108,13 @@ const button: Button = { .setCustomId("welcome") .setEmoji("1185973660465500180") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.welcome") + client.translation.get( + guildDb?.language, + "Settings.button.welcome", + ), ) .setStyle( - guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomePing") @@ -114,12 +122,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomePing" - ) + "Settings.button.welcomePing", + ), ) .setStyle( - guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); const welcomeButtons3 = @@ -130,11 +138,13 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeMessage" - ) + "Settings.button.welcomeMessage", + ), ) .setStyle( - guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeMessage + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeEmbedEdit") @@ -142,10 +152,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedEdit" - ) + "Settings.button.welcomeEmbedEdit", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); await interaction.update({ diff --git a/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbedTitle.ts b/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbedTitle.ts index 66613509..8360136c 100644 --- a/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbedTitle.ts +++ b/src/buttons/welcomeMessages/welcomeEmbed/welcomeEmbedTitle.ts @@ -102,4 +102,4 @@ const button: Button = { }, }; -export default button; \ No newline at end of file +export default button; diff --git a/src/buttons/welcomeMessages/welcomeEmbedEdit.ts b/src/buttons/welcomeMessages/welcomeEmbedEdit.ts index 071c15cb..8cdb9fe9 100644 --- a/src/buttons/welcomeMessages/welcomeEmbedEdit.ts +++ b/src/buttons/welcomeMessages/welcomeEmbedEdit.ts @@ -43,13 +43,13 @@ export function embed({ }) { return new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") + client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle"), ) .setFields([ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeContent" + "Settings.embed.welcomeContent", ), value: `\`\`\`${content.slice(0, 400)}\`\`\``, inline: false, @@ -57,7 +57,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeTitles" + "Settings.embed.welcomeTitles", ), value: `\`\`\`${title.slice(0, 100)}\`\`\``, inline: true, @@ -65,7 +65,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeTitlesURL" + "Settings.embed.welcomeTitlesURL", ), value: `\`\`\`${titleURL.slice(0, 30)}\`\`\``, inline: true, @@ -73,7 +73,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeDescription" + "Settings.embed.welcomeDescription", ), value: `\`\`\`${description.slice(0, 800)}\`\`\``, inline: false, @@ -81,7 +81,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeAuthorName" + "Settings.embed.welcomeAuthorName", ), value: `\`\`\`${author.slice(0, 100)}\`\`\``, inline: false, @@ -89,7 +89,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeAuthorURL" + "Settings.embed.welcomeAuthorURL", ), value: `\`\`\`${authorURL.slice(0, 30)}\`\`\``, inline: true, @@ -97,7 +97,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeThumbnailURL" + "Settings.embed.welcomeThumbnailURL", ), value: `\`\`\`${thumbnail.slice(0, 30)}\`\`\``, inline: true, @@ -105,7 +105,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeFooterText" + "Settings.embed.welcomeFooterText", ), value: `\`\`\`${footer.slice(0, 100)}\`\`\``, inline: false, @@ -113,7 +113,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeFooterURL" + "Settings.embed.welcomeFooterURL", ), value: `\`\`\`${footerURL.slice(0, 50)}\`\`\``, inline: true, @@ -121,7 +121,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeImageURL" + "Settings.embed.welcomeImageURL", ), value: `\`\`\`${image.slice(0, 50)}\`\`\``, inline: true, @@ -129,7 +129,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeColor" + "Settings.embed.welcomeColor", ), value: `\`\`\`${color}\`\`\``, inline: false, @@ -137,7 +137,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeTimestamp" + "Settings.embed.welcomeTimestamp", ), value: `\`\`\`${timestamp === true ? "✅" : "❌"}\`\`\``, inline: true, @@ -145,7 +145,7 @@ export function embed({ { name: client.translation.get( guildDb?.language, - "Settings.embed.welcomeToggle" + "Settings.embed.welcomeToggle", ), value: `\`\`\`${toggle === true ? "✅" : "❌"}\`\`\``, inline: true, @@ -188,8 +188,8 @@ export function Button1({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedTitle" - ) + "Settings.button.welcomeEmbedTitle", + ), ) .setStyle(title) .setEmoji("1185973664538177557"), @@ -199,8 +199,8 @@ export function Button1({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedDescription" - ) + "Settings.button.welcomeEmbedDescription", + ), ) .setStyle(description), new ButtonBuilder() @@ -209,8 +209,8 @@ export function Button1({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedAuthorName" - ) + "Settings.button.welcomeEmbedAuthorName", + ), ) .setStyle(author), new ButtonBuilder() @@ -218,11 +218,11 @@ export function Button1({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedAuthorURL" - ) + "Settings.button.welcomeEmbedAuthorURL", + ), ) .setStyle(authorURL) - .setEmoji("1185973664538177557") + .setEmoji("1185973664538177557"), ); } @@ -252,8 +252,8 @@ export function Button2({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedThumbnail" - ) + "Settings.button.welcomeEmbedThumbnail", + ), ) .setStyle(thumbnail), new ButtonBuilder() @@ -262,8 +262,8 @@ export function Button2({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedImage" - ) + "Settings.button.welcomeEmbedImage", + ), ) .setStyle(image), new ButtonBuilder() @@ -272,10 +272,10 @@ export function Button2({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedTimestamp" - ) + "Settings.button.welcomeEmbedTimestamp", + ), ) - .setStyle(timestamp) + .setStyle(timestamp), ); } @@ -305,8 +305,8 @@ export function Button3({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedFooterText" - ) + "Settings.button.welcomeEmbedFooterText", + ), ) .setStyle(footer), new ButtonBuilder() @@ -315,8 +315,8 @@ export function Button3({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedFooterURL" - ) + "Settings.button.welcomeEmbedFooterURL", + ), ) .setStyle(footerURL), new ButtonBuilder() @@ -325,10 +325,10 @@ export function Button3({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedColor" - ) + "Settings.button.welcomeEmbedColor", + ), ) - .setStyle(color) + .setStyle(color), ); } @@ -354,8 +354,8 @@ export function Button4({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedContent" - ) + "Settings.button.welcomeEmbedContent", + ), ) .setStyle(content), new ButtonBuilder() @@ -364,8 +364,8 @@ export function Button4({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedToggle" - ) + "Settings.button.welcomeEmbedToggle", + ), ) .setStyle(toggle), new ButtonBuilder() @@ -374,10 +374,10 @@ export function Button4({ .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbed" - ) + "Settings.button.welcomeEmbed", + ), ) - .setStyle(embed) + .setStyle(embed), ); } @@ -388,14 +388,14 @@ export function SelectMenu(client: any, guildDb: any) { .setPlaceholder( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedDeleteSettings" - ) + "Settings.button.welcomeEmbedDeleteSettings", + ), ) .addOptions([ { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedAuthorNameMenu" + "Settings.button.welcomeEmbedAuthorNameMenu", ), value: "author", description: "Delete the author name.", @@ -403,7 +403,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedAuthorURLMenu" + "Settings.button.welcomeEmbedAuthorURLMenu", ), value: "authorURL", description: "Delete the author URL.", @@ -411,7 +411,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedTitleMenu" + "Settings.button.welcomeEmbedTitleMenu", ), value: "title", description: "Delete the title.", @@ -420,7 +420,7 @@ export function SelectMenu(client: any, guildDb: any) { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedTitleMenu" + "Settings.button.welcomeEmbedTitleMenu", ) + " URL", value: "titleURL", description: "Delete the title URL.", @@ -428,7 +428,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedDescriptionMenu" + "Settings.button.welcomeEmbedDescriptionMenu", ), value: "description", description: "Delete the description.", @@ -436,7 +436,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedContentMenu" + "Settings.button.welcomeEmbedContentMenu", ), value: "content", description: "Delete the content.", @@ -444,7 +444,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedThumbnailMenu" + "Settings.button.welcomeEmbedThumbnailMenu", ), value: "thumbnail", description: "Delete the thumbnail.", @@ -452,7 +452,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedImageMenu" + "Settings.button.welcomeEmbedImageMenu", ), value: "image", description: "Delete the image.", @@ -460,7 +460,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedFooterTextMenu" + "Settings.button.welcomeEmbedFooterTextMenu", ), value: "footer", description: "Delete the footer text.", @@ -468,7 +468,7 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedFooterURLMenu" + "Settings.button.welcomeEmbedFooterURLMenu", ), value: "footerURL", description: "Delete the footer URL.", @@ -476,12 +476,12 @@ export function SelectMenu(client: any, guildDb: any) { { label: client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedColorMenu" + "Settings.button.welcomeEmbedColorMenu", ), value: "color", description: "Delete the color.", }, - ]) + ]), ); } diff --git a/src/buttons/welcomeMessages/welcomeMessage.ts b/src/buttons/welcomeMessages/welcomeMessage.ts index c624d1d5..8856a338 100644 --- a/src/buttons/welcomeMessages/welcomeMessage.ts +++ b/src/buttons/welcomeMessages/welcomeMessage.ts @@ -49,31 +49,34 @@ const button: Button = { const welcomeEmbed = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") + client.translation.get( + guildDb?.language, + "Settings.embed.welcomeTitle", + ), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.welcome" + "Settings.embed.welcome", )}: ${guildDb.welcome ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomePing" + "Settings.embed.welcomePing", )}: ${guildDb.welcomePing ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.dailyType" + "Settings.embed.dailyType", )}: ${guildDb.welcomeType}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeChannel" + "Settings.embed.welcomeChannel", )}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeMessage" - )}: ${truncateString(value, 100)}` + "Settings.embed.welcomeMessage", + )}: ${truncateString(value, 100)}`, ) .setColor("#0598F6") .setFooter({ text: client.translation.get( guildDb?.language, - "Settings.embed.footer" + "Settings.embed.footer", ), iconURL: client?.user?.displayAvatarURL() || undefined, }); @@ -88,8 +91,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -98,29 +101,31 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeChannel" - ) + "Settings.button.welcomeChannel", + ), ) .setStyle( - guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeChannel + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeTest") .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeTest" - ) + "Settings.button.welcomeTest", + ), ) .setDisabled( - guildDb.welcomeChannel && guildDb?.welcome ? false : true + guildDb.welcomeChannel && guildDb?.welcome ? false : true, ) .setStyle( guildDb.welcomeChannel && guildDb?.welcome ? ButtonStyle.Primary - : ButtonStyle.Secondary + : ButtonStyle.Secondary, ) - .setEmoji("1207800685928910909") + .setEmoji("1207800685928910909"), ); // Second button row @@ -131,10 +136,13 @@ const button: Button = { .setCustomId("welcome") .setEmoji("1185973660465500180") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.welcome") + client.translation.get( + guildDb?.language, + "Settings.button.welcome", + ), ) .setStyle( - guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomePing") @@ -142,12 +150,12 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomePing" - ) + "Settings.button.welcomePing", + ), ) .setStyle( - guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); const welcomeButtons3 = @@ -158,11 +166,13 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeMessage" - ) + "Settings.button.welcomeMessage", + ), ) .setStyle( - guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeMessage + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeEmbedEdit") @@ -170,10 +180,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedEdit" - ) + "Settings.button.welcomeEmbedEdit", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/buttons/welcomeMessages/welcomePing.ts b/src/buttons/welcomeMessages/welcomePing.ts index aa16b95f..6f8d45f7 100644 --- a/src/buttons/welcomeMessages/welcomePing.ts +++ b/src/buttons/welcomeMessages/welcomePing.ts @@ -23,35 +23,38 @@ const button: Button = { const welcomes = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") + client.translation.get( + guildDb?.language, + "Settings.embed.welcomeTitle", + ), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.welcome" + "Settings.embed.welcome", )}: ${guildDb.welcome ? ":white_check_mark:" : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomePing" + "Settings.embed.welcomePing", )}: ${check ? ":x:" : ":white_check_mark:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.dailyType" + "Settings.embed.dailyType", )}: ${guildDb.welcomeType}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeChannel" + "Settings.embed.welcomeChannel", )}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get( guildDb?.language, - "Settings.embed.welcomeMessage" + "Settings.embed.welcomeMessage", )}: ${ guildDb.welcomeMessage ? truncateString(guildDb.welcomeMessage, 100) : ":x:" - }` + }`, ) .setColor("#0598F6") .setFooter({ text: client.translation.get( guildDb?.language, - "Settings.embed.footer" + "Settings.embed.footer", ), iconURL: client?.user?.displayAvatarURL() || undefined, }); @@ -64,8 +67,8 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyType" - ) + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary) .setEmoji("1185973667973320775"), @@ -75,29 +78,31 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeChannel" - ) + "Settings.button.welcomeChannel", + ), ) .setStyle( - guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeChannel + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeTest") .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeTest" - ) + "Settings.button.welcomeTest", + ), ) .setDisabled( - guildDb.welcomeChannel && guildDb?.welcome ? false : true + guildDb.welcomeChannel && guildDb?.welcome ? false : true, ) .setStyle( guildDb.welcomeChannel && guildDb?.welcome ? ButtonStyle.Primary - : ButtonStyle.Secondary + : ButtonStyle.Secondary, ) - .setEmoji("1207800685928910909") + .setEmoji("1207800685928910909"), ); const welcomeButtons2 = new ActionRowBuilder().addComponents( @@ -105,10 +110,13 @@ const button: Button = { .setCustomId("welcome") .setEmoji("1185973660465500180") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.welcome") + client.translation.get( + guildDb?.language, + "Settings.button.welcome", + ), ) .setStyle( - guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomePing") @@ -116,10 +124,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomePing" - ) + "Settings.button.welcomePing", + ), ) - .setStyle(check ? ButtonStyle.Secondary : ButtonStyle.Success) + .setStyle(check ? ButtonStyle.Secondary : ButtonStyle.Success), ); const welcomeButtons3 = @@ -130,11 +138,13 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeMessage" - ) + "Settings.button.welcomeMessage", + ), ) .setStyle( - guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.welcomeMessage + ? ButtonStyle.Primary + : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("welcomeEmbedEdit") @@ -142,10 +152,10 @@ const button: Button = { .setLabel( client.translation.get( guildDb?.language, - "Settings.button.welcomeEmbedEdit" - ) + "Settings.button.welcomeEmbedEdit", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); await client.database.updateGuild(interaction.guild?.id || "", { diff --git a/src/commands/index.ts b/src/commands/index.ts index faff34a7..a4f6138d 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -149,6 +149,25 @@ const commandInteractionEvent: Event = { client, guildDb as IGuildModel, ) + .then(async () => { + if (guildDb && guildDb?.dmsError) { + const repliedMessage = await interaction.fetchReply(); + await repliedMessage + .reply({ + embeds: [ + { + title: + "Hello, sorry to bother you, but Would You encountered an error in its Daily Message system.", + description: `The error is as follows:\n${guildDb.dmsError}\n\nIf you aren't an administrator for this server, please contact them and send them this message for them to fix.\n**Support Server**: https://discord.gg/vMyXAxEznS`, + color: 0xffcc00, + }, + ], + }) + .catch(() => {}); + + client.database.updateGuild(guildDb.guildID, { dmsError: null }); + } + }) .catch((err: Error) => { captureException(err); return interaction.reply({ diff --git a/src/commands/settings/custom.ts b/src/commands/settings/custom.ts index a5217dc9..52e21071 100644 --- a/src/commands/settings/custom.ts +++ b/src/commands/settings/custom.ts @@ -27,7 +27,6 @@ const command: ChatInputCommand = { .setDescription("Lets you manage your own questions") .setContexts([0]) .setIntegrationTypes([0]) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) .setDescriptionLocalizations({ de: "Fügt eigene WouldYou Fragen hinzu", "es-ES": "Añade mensajes Would You personalizados", @@ -109,9 +108,13 @@ const command: ChatInputCommand = { let generativeText: any; if ( - (interaction?.member?.permissions as Readonly).has( - PermissionFlagsBits.ManageGuild, - ) + guildDb.customPerm + ? (interaction?.member?.roles as Readonly).cache.has( + guildDb.customPerm, + ) + : ( + interaction?.member?.permissions as Readonly + ).has(PermissionFlagsBits.ManageGuild) ) { switch (interaction.options.getSubcommand()) { case "add": { @@ -737,25 +740,29 @@ const command: ChatInputCommand = { return; } - const all = []; - for (const key in response.data) { - if (!response.data.hasOwnProperty(key)) continue; - if ( - guildDb.customMessages.filter((e) => e.type === key).length + - response.data[key].length > - 100 - ) - all.push(key); + let prem = []; + if (!(await client.premium.check(interaction.guildId)).result) { + prem.push(true); } + const all = []; for (const key in response.data) { if (!response.data.hasOwnProperty(key)) continue; if ( - !(await client.premium.check(interaction.guildId)).result && + prem.length > 0 && guildDb.customMessages.filter((e) => e.type === key).length + response.data[key].length > 100 ) { + if (!response.data.hasOwnProperty(key)) continue; + if ( + guildDb.customMessages.filter((e) => e.type === key) + .length + + response.data[key].length > + 100 + ) + all.push(key); + const premiumButton = new ActionRowBuilder().addComponents( new ButtonBuilder() @@ -798,7 +805,7 @@ const command: ChatInputCommand = { (e) => e.type === "wouldyourather", ).length; response.data.wouldyourather.map((d: any) => { - if (i === 100) return; + if (prem.length > 0 && i === 100) return; i++; const newID = uuidv4(); guildDb.customMessages.push({ @@ -814,7 +821,7 @@ const command: ChatInputCommand = { (e) => e.type === "truth", ).length; response.data.truth.map((d: any) => { - if (i === 100) return; + if (prem.length > 0 && i === 100) return; i++; const newID = uuidv4(); guildDb.customMessages.push({ @@ -830,7 +837,7 @@ const command: ChatInputCommand = { (e) => e.type === "dare", ).length; response.data.dare.map((d: any) => { - if (i === 100) return; + if (prem.length > 0 && i === 100) return; i++; const newID = uuidv4(); guildDb.customMessages.push({ @@ -846,7 +853,7 @@ const command: ChatInputCommand = { (e) => e.type === "neverhaveiever", ).length; response.data.neverhaveiever.map((d: any) => { - if (i === 100) return; + if (prem.length > 0 && i === 100) return; i++; const newID = uuidv4(); @@ -863,7 +870,7 @@ const command: ChatInputCommand = { (e) => e.type === "wwyd", ).length; response.data.wwyd.map((d: any) => { - if (i === 100) return; + if (prem.length > 0 && i === 100) return; i++; const newID = uuidv4(); @@ -1017,11 +1024,18 @@ const command: ChatInputCommand = { } } } else { + console.log(guildDb.customPerm); const errorembed = new EmbedBuilder() .setColor("#F00505") .setTitle("Error!") .setDescription( - client.translation.get(guildDb?.language, "Language.embed.error"), + guildDb.customPerm + ? client.translation.get( + guildDb?.language, + "Language.embed.errorRole", + { role: `<@&${guildDb.customPerm}>` }, + ) + : client.translation.get(guildDb?.language, "Language.embed.error"), ); interaction .reply({ diff --git a/src/commands/settings/settings-subcommands/qotd.ts b/src/commands/settings/settings-subcommands/qotd.ts index c4c96a32..d0169898 100644 --- a/src/commands/settings/settings-subcommands/qotd.ts +++ b/src/commands/settings/settings-subcommands/qotd.ts @@ -12,36 +12,36 @@ import type WouldYou from "../../../util/wouldYou"; export default async function settingsGeneral( interaction: ChatInputCommandInteraction, client: WouldYou, - guildDb: IGuildModel + guildDb: IGuildModel, ) { const emb = new EmbedBuilder() .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.dailyTitle") + client.translation.get(guildDb?.language, "Settings.embed.dailyTitle"), ) .setDescription( `${client.translation.get( guildDb?.language, - "Settings.embed.dailyChannel" + "Settings.embed.dailyChannel", )}: ${guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyRole" + "Settings.embed.dailyRole", )}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyType")}: ${guildDb?.customTypes}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyTimezone")}: ${guildDb.dailyTimezone}\n` + `${client.translation.get(guildDb?.language, "Settings.embed.dailyInterval")}: ${guildDb.dailyInterval}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyThread" + "Settings.embed.dailyThread", )}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.autoPin" + "Settings.embed.autoPin", )}: ${guildDb.autoPin ? ":white_check_mark:" : ":x:"}\n` + `${client.translation.get( guildDb?.language, - "Settings.embed.dailyMsg" - )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}` + "Settings.embed.dailyMsg", + )}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}`, ) .setColor("#0598F6"); @@ -55,26 +55,32 @@ export default async function settingsGeneral( .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyChannel" - ) + "Settings.button.dailyChannel", + ), ) .setStyle( - guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyChannel ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyRole") .setEmoji("1185973666811478117") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.dailyRole") + client.translation.get( + guildDb?.language, + "Settings.button.dailyRole", + ), ) .setStyle( - guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary + guildDb.dailyRole ? ButtonStyle.Primary : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyType") .setEmoji("1185973664538177557") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.dailyType") + client.translation.get( + guildDb?.language, + "Settings.button.dailyType", + ), ) .setStyle(ButtonStyle.Primary), new ButtonBuilder() @@ -83,10 +89,10 @@ export default async function settingsGeneral( .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyQuestionType" - ) + "Settings.button.dailyQuestionType", + ), ) - .setStyle(ButtonStyle.Primary) + .setStyle(ButtonStyle.Primary), ); // Second button row @@ -99,11 +105,11 @@ export default async function settingsGeneral( .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyTimezone" - ) + "Settings.button.dailyTimezone", + ), ) .setStyle( - guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyTimezone ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyInterval") @@ -111,19 +117,22 @@ export default async function settingsGeneral( .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyInterval" - ) + "Settings.button.dailyInterval", + ), ) .setStyle( - guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyInterval ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("daySelection") .setEmoji("1220826970133368842") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.daySelect") + client.translation.get( + guildDb?.language, + "Settings.button.daySelect", + ), ) - .setStyle(ButtonStyle.Success) + .setStyle(ButtonStyle.Success), ); // Third button row @@ -136,30 +145,30 @@ export default async function settingsGeneral( .setLabel( client.translation.get( guildDb?.language, - "Settings.button.dailyThread" - ) + "Settings.button.dailyThread", + ), ) .setStyle( - guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.dailyThread ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("autoPin") .setEmoji("1189521962318450698") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.autoPin") + client.translation.get(guildDb?.language, "Settings.button.autoPin"), ) .setStyle( - guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary + guildDb.autoPin ? ButtonStyle.Success : ButtonStyle.Secondary, ), new ButtonBuilder() .setCustomId("dailyMsg") .setEmoji("1185973660465500180") .setLabel( - client.translation.get(guildDb?.language, "Settings.button.dailyMsg") + client.translation.get(guildDb?.language, "Settings.button.dailyMsg"), ) .setStyle( - guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary - ) + guildDb.dailyMsg ? ButtonStyle.Success : ButtonStyle.Secondary, + ), ); await interaction diff --git a/src/commands/settings/settings-subcommands/utility.ts b/src/commands/settings/settings-subcommands/utility.ts index 01b17695..dd67688a 100644 --- a/src/commands/settings/settings-subcommands/utility.ts +++ b/src/commands/settings/settings-subcommands/utility.ts @@ -20,6 +20,9 @@ export default async function settingsGeneral( ) .setDescription( `${client.translation.get( + guildDb?.language, + "Settings.embed.customPerm", + )}: ${guildDb.customPerm ? `<@&${guildDb.customPerm}>` : ":x:"}\n${client.translation.get( guildDb?.language, "Settings.embed.username", )}: ${guildDb.webhookName ? guildDb.webhookName : ":x:"}\n${client.translation.get( @@ -28,7 +31,7 @@ export default async function settingsGeneral( )}: ${guildDb.webhookAvatar ? `[Image](<${guildDb.webhookAvatar}>)` : ":x:"}\n${client.translation.get( guildDb?.language, "Settings.embed.classicMode", - )}: ${guildDb.classicMode ? ":white_check_mark:" : ":x:"}`, + )}: ${guildDb.classicMode ? ":x:" : ":white_check_mark:"}`, ) .setColor("#0598F6") .setFooter({ @@ -44,9 +47,7 @@ export default async function settingsGeneral( .setLabel( client.translation.get(guildDb?.language, "Settings.button.name"), ) - .setStyle( - guildDb.webhookName ? ButtonStyle.Success : ButtonStyle.Secondary, - ), + .setStyle(ButtonStyle.Success), new ButtonBuilder() .setCustomId("webhookAvatar") .setEmoji("1207801424503644260") @@ -70,7 +71,19 @@ export default async function settingsGeneral( ), ) .setStyle( - guildDb.classicMode ? ButtonStyle.Success : ButtonStyle.Secondary, + guildDb.classicMode ? ButtonStyle.Secondary : ButtonStyle.Success, + ), + new ButtonBuilder() + .setCustomId("customPerm") + .setEmoji("1256977616242606091") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.customPerm", + ), + ) + .setStyle( + guildDb.customPerm ? ButtonStyle.Success : ButtonStyle.Secondary, ), ); diff --git a/src/commands/settings/settings-subcommands/welcomes.ts b/src/commands/settings/settings-subcommands/welcomes.ts index 2a1839af..05dbd380 100644 --- a/src/commands/settings/settings-subcommands/welcomes.ts +++ b/src/commands/settings/settings-subcommands/welcomes.ts @@ -12,7 +12,7 @@ import type WouldYou from "../../../util/wouldYou"; export default async function settingsGeneral( interaction: ChatInputCommandInteraction, client: WouldYou, - guildDb: IGuildModel + guildDb: IGuildModel, ) { const truncateString = (str: string, maxLength: number) => { const cleanedStr = str.replace(/\n/g, " "); @@ -22,138 +22,155 @@ export default async function settingsGeneral( }; try { + const welcomeEmbed = new EmbedBuilder() + .setTitle( + client.translation.get( + guildDb?.language, + "Settings.embed.welcomeTitle", + ), + ) + .setDescription( + `${client.translation.get( + guildDb?.language, + "Settings.embed.welcome", + )}: ${guildDb.welcome ? ":white_check_mark:" : ":x:"}\n${client.translation.get( + guildDb?.language, + "Settings.embed.welcomePing", + )}: ${guildDb.welcomePing ? ":white_check_mark:" : ":x:"}\n${client.translation.get( + guildDb?.language, + "Settings.embed.dailyType", + )}: ${guildDb.welcomeType}\n${client.translation.get( + guildDb?.language, + "Settings.embed.welcomeChannel", + )}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get( + guildDb?.language, + "Settings.embed.welcomeMessage", + )}: ${ + guildDb.welcomeMessage + ? truncateString(guildDb.welcomeMessage, 100) + : ":x:" + }`, + ) + .setColor("#0598F6") + .setFooter({ + text: client.translation.get( + guildDb?.language, + "Settings.embed.footer", + ), + iconURL: client?.user?.displayAvatarURL() || undefined, + }); - const welcomeEmbed = new EmbedBuilder() - .setTitle( - client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle") - ) - .setDescription( - `${client.translation.get( - guildDb?.language, - "Settings.embed.welcome" - )}: ${guildDb.welcome ? ":white_check_mark:" : ":x:"}\n${client.translation.get( - guildDb?.language, - "Settings.embed.welcomePing" - )}: ${guildDb.welcomePing ? ":white_check_mark:" : ":x:"}\n${client.translation.get( - guildDb?.language, - "Settings.embed.dailyType" - )}: ${guildDb.welcomeType}\n${client.translation.get( - guildDb?.language, - "Settings.embed.welcomeChannel" - )}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get( - guildDb?.language, - "Settings.embed.welcomeMessage" - )}: ${ - guildDb.welcomeMessage - ? truncateString(guildDb.welcomeMessage, 100) - : ":x:" - }` - ) - .setColor("#0598F6") - .setFooter({ - text: client.translation.get(guildDb?.language, "Settings.embed.footer"), - iconURL: client?.user?.displayAvatarURL() || undefined, - }); - - // First button row - // Deals with toggles - const welcomeButtons1 = - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("welcomeType") - .setEmoji("1185973664538177557") - .setLabel( - client.translation.get(guildDb?.language, "Settings.button.dailyType") - ) - .setStyle(ButtonStyle.Primary), - new ButtonBuilder() - .setCustomId("welcomeChannel") - .setEmoji("1185973667973320775") - .setLabel( - client.translation.get( - guildDb?.language, - "Settings.button.welcomeChannel" + // First button row + // Deals with toggles + const welcomeButtons1 = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("welcomeType") + .setEmoji("1185973664538177557") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.dailyType", + ), ) - ) - .setStyle( - guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary - ), - new ButtonBuilder() - .setCustomId("welcomeTest") - .setLabel( - client.translation.get( - guildDb?.language, - "Settings.button.welcomeTest" + .setStyle(ButtonStyle.Primary), + new ButtonBuilder() + .setCustomId("welcomeChannel") + .setEmoji("1185973667973320775") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.welcomeChannel", + ), + ) + .setStyle( + guildDb.welcomeChannel + ? ButtonStyle.Primary + : ButtonStyle.Secondary, + ), + new ButtonBuilder() + .setCustomId("welcomeTest") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.welcomeTest", + ), ) - ) - .setDisabled(guildDb.welcomeChannel && guildDb?.welcome ? false : true) - .setStyle( - guildDb.welcomeChannel && guildDb?.welcome - ? ButtonStyle.Primary - : ButtonStyle.Secondary - ) - .setEmoji("1207800685928910909") - ); + .setDisabled( + guildDb.welcomeChannel && guildDb?.welcome ? false : true, + ) + .setStyle( + guildDb.welcomeChannel && guildDb?.welcome + ? ButtonStyle.Primary + : ButtonStyle.Secondary, + ) + .setEmoji("1207800685928910909"), + ); - // Second button row - // Deals with type, channel, test - const welcomeButtons2 = - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("welcome") - .setEmoji("1185973660465500180") - .setLabel( - client.translation.get(guildDb?.language, "Settings.button.welcome") - ) - .setStyle( - guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary - ), - new ButtonBuilder() - .setCustomId("welcomePing") - .setEmoji("1207801424503644260") - .setLabel( - client.translation.get( - guildDb?.language, - "Settings.button.welcomePing" + // Second button row + // Deals with type, channel, test + const welcomeButtons2 = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("welcome") + .setEmoji("1185973660465500180") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.welcome", + ), ) - ) - .setStyle( - guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary - ) - ); + .setStyle( + guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary, + ), + new ButtonBuilder() + .setCustomId("welcomePing") + .setEmoji("1207801424503644260") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.welcomePing", + ), + ) + .setStyle( + guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary, + ), + ); - const welcomeButtons3 = - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("welcomeMessage") - .setEmoji("1185973660465500180") - .setLabel( - client.translation.get( - guildDb?.language, - "Settings.button.welcomeMessage" + const welcomeButtons3 = + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("welcomeMessage") + .setEmoji("1185973660465500180") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.welcomeMessage", + ), ) - ) - .setStyle( - guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary - ), - new ButtonBuilder() - .setCustomId("welcomeEmbedEdit") - .setEmoji("1308673732478238740") - .setLabel( - client.translation.get( - guildDb?.language, - "Settings.button.welcomeEmbedEdit" + .setStyle( + guildDb.welcomeMessage + ? ButtonStyle.Primary + : ButtonStyle.Secondary, + ), + new ButtonBuilder() + .setCustomId("welcomeEmbedEdit") + .setEmoji("1308673732478238740") + .setLabel( + client.translation.get( + guildDb?.language, + "Settings.button.welcomeEmbedEdit", + ), ) - ) - .setStyle(ButtonStyle.Primary) - ); + .setStyle(ButtonStyle.Primary), + ); - await interaction.reply({ - embeds: [welcomeEmbed], - components: [welcomeButtons2, welcomeButtons1, welcomeButtons3], - ephemeral: true, - }); + await interaction.reply({ + embeds: [welcomeEmbed], + components: [welcomeButtons2, welcomeButtons1, welcomeButtons3], + ephemeral: true, + }); } catch (e) { - console.log(e) + console.log(e); } } diff --git a/src/commands/utility/info.ts b/src/commands/utility/info.ts index 84b1646a..db0030f8 100644 --- a/src/commands/utility/info.ts +++ b/src/commands/utility/info.ts @@ -1,7 +1,10 @@ import { captureException } from "@sentry/node"; import { EmbedBuilder, SlashCommandBuilder } from "discord.js"; import type { ChatInputCommand } from "../../interfaces"; -const { version } = require("../../../package.json"); +import { + type IShardClusterStore, + shardClusterStoreModel, +} from "../../util/Models/ShardClusterStore"; const command: ChatInputCommand = { requireGuild: true, @@ -26,6 +29,7 @@ const command: ChatInputCommand = { const userCount = await client.cluster.broadcastEval((c) => c.guilds.cache.reduce((a, b) => a + b.memberCount, 0), ); + const ramUsage = await client.cluster.broadcastEval(() => { function round(num: number) { const m = Number((Math.abs(num) * 100).toPrecision(15)); @@ -40,54 +44,62 @@ const command: ChatInputCommand = { const premium = await client.premium.check(interaction.guildId); - const premiumEmoji = premium.result ? "✅" : "❌"; - - const { dominik, sky, skelly, paulos, tee, woofer } = client.config.emojis.info; + const { dominik, sky, skelly, paulos, tee, woofer } = + client.config.emojis.info; const infoEmbed = new EmbedBuilder() .setColor("#0598F6") - .setTitle("Bot Info") - .addFields( - { - name: "Developers:", - value: `${dominik + sky + skelly + paulos + tee + woofer}`, - inline: false, - }, - { - name: "Servercount:", - value: `${serverCount.reduce((prev, val) => prev + val, 0).toLocaleString()}`, - inline: false, - }, - { - name: "Users:", - value: `${userCount.reduce((a, b) => a + b, 0).toLocaleString()}`, - inline: false, - }, - { - name: "Memory:", - value: `${ramUsage.reduce((acc, usage) => acc + usage, 0).toLocaleString()}GB`, - inline: false, - }, - { - name: "Last Restart:", - value: ` - `, - inline: false, - }, - { - name: "Bot Version:", - value: `v${version}`, - inline: false, - }, - { - name: "Premium Server:", - value: `${`${premiumEmoji} ${premium.result}`}`, - inline: false, - }, + .setDescription( + `# Info about Would You +Devs: ${dominik + sky + skelly + paulos + tee + woofer} +Servers: ${serverCount.reduce((prev, val) => prev + val, 0).toLocaleString()} +Users: ${userCount.reduce((a, b) => a + b, 0).toLocaleString()} +Memory: ${ramUsage.reduce((acc, usage) => acc + usage, 0).toLocaleString()}GB +Last Restart: +## Shard Information +\`\`\`ini +${await shardClusterStoreModel + .find() + .then((shards: IShardClusterStore[]) => + shards.reduce((acc, shard) => { + const clusters = new Map(); + shards.forEach((s) => { + if (!clusters.has(s.cluster)) clusters.set(s.cluster, []); + clusters.get(s.cluster)?.push(s); + }); + + return Array.from(clusters.entries()) + .map(([clusterId, clusterShards]) => { + const sortedShards = clusterShards + .map((s) => s.shard) + .sort((a, b) => a - b); + const shardGroups = sortedShards.reduce( + (groups: string[], shard, i) => { + const groupIndex = Math.floor(i / 8); + if (!groups[groupIndex]) groups[groupIndex] = ""; + groups[groupIndex] += (groups[groupIndex] ? ", " : "") + shard; + return groups; + }, + [], + ); + + return `[Cluster ${clusterId}]\n${shardGroups.join("\n")}`; + }) + .join("\n\n"); + }, ""), + ) + .catch(() => "No Shard Data found")} +\`\`\` +### Useful Links +-# [Support Server](https://wouldyoubot.gg/discord) +-# [Website](https://wouldyoubot.gg) +-# [Invite Link](https://wouldyoubot.gg/invite) +-# [Privacy Policy](https://wouldyoubot.gg/privacy) +-# [Terms of Service](https://wouldyoubot.gg/terms) +-# [Legal](https://wouldyoubot.gg/legal)`, ) - .setThumbnail("https://wouldyoubot.gg/Logo.png") .setFooter({ - text: `${interaction.user.tag} | Shard #${interaction?.guild?.shardId} | Cluster #${client.cluster.id}`, + text: `Premium Status: ${premium.result ? premium.rawType : "Free"}`, iconURL: "https://wouldyoubot.gg/Logo.png", }); diff --git a/src/commands/utility/placeholders.ts b/src/commands/utility/placeholders.ts index 4adc5a95..0d6e8915 100644 --- a/src/commands/utility/placeholders.ts +++ b/src/commands/utility/placeholders.ts @@ -1,7 +1,7 @@ import { captureException } from "@sentry/node"; import { EmbedBuilder, - type GuildMember, + type GuildMember, SlashCommandBuilder, } from "discord.js"; import type { ChatInputCommand } from "../../interfaces"; @@ -11,43 +11,54 @@ const command: ChatInputCommand = { cooldown: true, data: new SlashCommandBuilder() .setName("placeholders") - .setDescription("Gives you a list of placeholders that you can use in your welcome messages") + .setDescription( + "Gives you a list of placeholders that you can use in your welcome messages", + ) .setContexts([0]) .setIntegrationTypes([0]) .setDescriptionLocalizations({ de: "Gibt dir eine Liste von Platzhaltern, die du in deinen Willkommensnachrichten verwenden kannst", - "es-ES": "Te da una lista de marcadores de posición que puedes usar en tus mensajes de bienvenida", + "es-ES": + "Te da una lista de marcadores de posición que puedes usar en tus mensajes de bienvenida", fr: "Vous donne une liste de placeholders que vous pouvez utiliser dans vos messages de bienvenue", it: "Ti fornisce un elenco di segnaposto che puoi utilizzare nei tuoi messaggi di benvenuto", }), execute: async (interaction, client, guildDb) => { - const member = interaction.member as GuildMember; const placeholderMap: Record = { "{{user_displayname}}": member.user.displayName, "{{user_tag}}": member.user.username, - "{{user_avatarUrl}}": member.user.avatarURL() ?? "https://cdn.discordapp.com/embed/avatars/5.png", + "{{user_avatarUrl}}": + member.user.avatarURL() ?? + "https://cdn.discordapp.com/embed/avatars/5.png", "{{@mention}}": `<@${member.user.id}>`, "{{guild_name}}": member.guild.name, "{{guild_member_count}}": member.guild.memberCount.toString(), - "{{guild_iconUrl}}": member.guild.iconURL() ?? "https://cdn.discordapp.com/embed/avatars/5.png", - "{{question}}": client.translation.get(guildDb.language, "Placeholders.embed.question"), + "{{guild_iconUrl}}": + member.guild.iconURL() ?? + "https://cdn.discordapp.com/embed/avatars/5.png", + "{{question}}": client.translation.get( + guildDb.language, + "Placeholders.embed.question", + ), "{{new_line}}": "\\n", }; const placeholderEmbed = new EmbedBuilder() .setColor("#0598F6") - .setTitle(client.translation.get(guildDb.language, "Placeholders.embed.title")) - .addFields( + .setTitle( + client.translation.get(guildDb.language, "Placeholders.embed.title"), + ) + .addFields( ...Object.entries(placeholderMap).map(([placeholder, value]) => ({ - name: placeholder, - value: value, - inline: false, - })), + name: placeholder, + value: value, + inline: false, + })), ); - + await interaction .reply({ embeds: [placeholderEmbed], diff --git a/src/commands/utility/sync.ts b/src/commands/utility/sync.ts index c89aef54..eab17c4b 100644 --- a/src/commands/utility/sync.ts +++ b/src/commands/utility/sync.ts @@ -35,7 +35,7 @@ const command: ChatInputCommand = { ephemeral: true, }); } - + const subscription = await stripe.subscriptions.search({ query: `metadata['serverId']:'${interaction.guildId}'`, }); diff --git a/src/commands/utility/vote.ts b/src/commands/utility/vote.ts index e3530303..03ef353c 100644 --- a/src/commands/utility/vote.ts +++ b/src/commands/utility/vote.ts @@ -24,20 +24,24 @@ const command: ChatInputCommand = { }), execute: async (interaction, client, guildDb) => { - const { topgg } = client.config.emojis.vote - + const { topgg } = client.config.emojis.vote; + const voteEmbed = new EmbedBuilder() .setAuthor({ name: client.translation.get(guildDb?.language, "Vote.embed.name"), iconURL: `https://cdn.discordapp.com/emojis/${topgg}.webp?size=512&quality=lossless`, }) .setColor("#FF3366") - .setDescription(client.translation.get(guildDb?.language, "Vote.embed.description"),) + .setDescription( + client.translation.get(guildDb?.language, "Vote.embed.description"), + ); const button = new ActionRowBuilder().addComponents( new ButtonBuilder() - .setLabel(client.translation.get(guildDb?.language, "Vote.button.label"),) + .setLabel( + client.translation.get(guildDb?.language, "Vote.button.label"), + ) .setStyle(5) .setEmoji(topgg) .setURL("https://top.gg/bot/981649513427111957/vote/"), diff --git a/src/config.ts b/src/config.ts index b94ab878..c7d09a41 100644 --- a/src/config.ts +++ b/src/config.ts @@ -17,8 +17,8 @@ const Config = { woofer: "<:Woofer:1321568826458116267>", }, vote: { - topgg: "1326947352409276438" - } + topgg: "1326947352409276438", + }, }, } as const; diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts index fb7f7ba4..8ddeb11a 100644 --- a/src/events/guildCreate.ts +++ b/src/events/guildCreate.ts @@ -47,10 +47,16 @@ const event: Event = { .addFields( { name: "Name", value: guild.name, inline: false }, { name: "ID", value: guild.id, inline: false }, - { name: "Users", value: guild.memberCount.toLocaleString(), inline: false }, + { + name: "Users", + value: guild.memberCount.toLocaleString(), + inline: false, + }, { name: "Server Owner", value: guild.ownerId, inline: false }, - ...(features ? [{ name: "Features", value: features, inline: false }] : []) - ) + ...(features + ? [{ name: "Features", value: features, inline: false }] + : []), + ), ], allowedMentions: { parse: [] }, }); diff --git a/src/events/guildDelete.ts b/src/events/guildDelete.ts index e93e78c7..8689659a 100644 --- a/src/events/guildDelete.ts +++ b/src/events/guildDelete.ts @@ -58,10 +58,16 @@ const event: Event = { .addFields([ { name: "Name", value: guild.name, inline: false }, { name: "ID", value: guild.id, inline: false }, - { name: "Users", value: guild.memberCount.toLocaleString(), inline: false }, + { + name: "Users", + value: guild.memberCount.toLocaleString(), + inline: false, + }, { name: "Server Owner", value: guild.ownerId, inline: false }, - ...(features ? [{ name: "Features", value: features, inline: false }] : []), - ]) + ...(features + ? [{ name: "Features", value: features, inline: false }] + : []), + ]), ], allowedMentions: { parse: [] }, }); diff --git a/src/events/guildMemberAdd.ts b/src/events/guildMemberAdd.ts index fe25d891..be8527c3 100644 --- a/src/events/guildMemberAdd.ts +++ b/src/events/guildMemberAdd.ts @@ -40,7 +40,8 @@ const event: Event = { const premium = await client.premium.check(member?.guild.id); - const randomType = Math.random() > 0.5 ? "wouldyourather" : "whatwouldyoudo"; + const randomType = + Math.random() > 0.5 ? "wouldyourather" : "whatwouldyoudo"; const randomMessage = await await getQuestionsByType( guildDb.welcomeChannel, @@ -48,17 +49,21 @@ const event: Event = { guildDb, guildDb?.language != null ? guildDb.language : "en_EN", premium.result, - false + false, ); const placeholderMap: Record = { "{{user_displayname}}": member.user.displayName, "{{user_tag}}": member.user.username, - "{{user_avatarUrl}}": member.user.avatarURL() ?? "https://cdn.discordapp.com/embed/avatars/5.png", + "{{user_avatarUrl}}": + member.user.avatarURL() ?? + "https://cdn.discordapp.com/embed/avatars/5.png", "{{@mention}}": `<@${member.user.id}>`, "{{guild_name}}": member.guild.name, "{{guild_member_count}}": member.guild.memberCount.toString(), - "{{guild_iconUrl}}": member.guild.iconURL() ?? "https://cdn.discordapp.com/embed/avatars/5.png", + "{{guild_iconUrl}}": + member.guild.iconURL() ?? + "https://cdn.discordapp.com/embed/avatars/5.png", "{{question}}": randomMessage.question, "{{new_line}}": "\n", }; @@ -68,7 +73,7 @@ const event: Event = { (msg, [placeholder, value]) => { return msg.replace(new RegExp(placeholder, "g"), value); }, - message + message, ); } @@ -83,13 +88,15 @@ const event: Event = { const embed = new EmbedBuilder() .setColor((guildDb.welcomeEmbedColor as ColorResolvable) || null) .setTitle( - guildDb?.welcomeEmbedTitle ? Message(guildDb.welcomeEmbedTitle) : null + guildDb?.welcomeEmbedTitle + ? Message(guildDb.welcomeEmbedTitle) + : null, ) .setURL(guildDb.welcomeEmbedTitleURL || null) .setDescription( guildDb?.welcomeEmbedDescription ? Message(guildDb.welcomeEmbedDescription) - : null + : null, ) .setThumbnail(guildDb.welcomeEmbedThumbnail || null) .setImage(guildDb.welcomeEmbedImage || null) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 243d4a70..4f46edae 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -16,6 +16,7 @@ const event: Event = { event: "messageCreate", execute: async (client: WouldYou, message: Message) => { // Always check the permissions before doing any actions to avoid a ratelimit IP ban =) + if (message?.member?.user.bot) return; if ( message.guild?.members.me && (message?.channel as GuildTextBasedChannel) @@ -55,26 +56,26 @@ const event: Event = { .setURL("https://discord.gg/vMyXAxEznS"), ); - Cooldown.add(message?.channel?.id); - setTimeout(() => { - Cooldown.delete(message?.channel?.id); - }, 10000); + // Cooldown.add(message?.channel?.id); + // setTimeout(() => { + // Cooldown.delete(message?.channel?.id); + // }, 10000); - if ( - message.content && - new RegExp(`^(<@!?${client?.user?.id}>)`).test(message.content) - ) - if (message.inGuild()) { - message.channel - .send({ - embeds: [embed], - components: [supportbutton], - }) - .catch((err: Error) => { - captureException(err); - }); - } - return; + // if ( + // message.content && + // new RegExp(`^(<@!?${client?.user?.id}>)`).test(message.content) + // ) + // if (message.inGuild()) { + // message.channel + // .send({ + // embeds: [embed], + // components: [supportbutton], + // }) + // .catch((err: Error) => { + // captureException(err); + // }); + // } + // return; } }, }; diff --git a/src/languages/de_DE.json b/src/languages/de_DE.json index 00fff8a9..adf9deaa 100644 --- a/src/languages/de_DE.json +++ b/src/languages/de_DE.json @@ -19,6 +19,7 @@ "Language": { "embed": { "error": "Dir fehlt die `ManageGuild` permission!", + "errorRole": "Sie müssen die Rolle **{role}** haben, um diesen Befehl zu benutzen!", "footer": "Would You" } }, @@ -225,7 +226,7 @@ }, "Settings": { "errorSame": "Die gegebene Zeitzone ist die gleiche Zeitzone, die schon gesetzt ist. Stelle sicher, dass du eine andere Zeitzone wählst.", - "errorInvalid": "Die gegebene Zeitzone ist ungültig, du kannst eine gültige Zeitzone von diesen auswählen [Zeitzonenwähler](https://kevinnovak.github.io/Time-Zone-Picker/)", + "errorInvalid": "Die gegebene Zeitzone ist ungültig, du kannst eine gültige Zeitzone von diesen auswählen [Zeitzonenwähler](https://zones.arilyn.cc/)", "intervalSame": "Die angegebene Veröffentlichungszeit ist die gleiche wie die bereits gesetzte. Stelle sicher, dass du einen andere Veröffentlichungszeit wählst.", "intervalInvalid": "Die angegebene Veröffentlichungszeit war ungültig. Stelle sicher, dass deine Veröffentlichungszeit im 24h-Format ist und entweder mit 00 oder einem 5-Minuten-Intervall endet!", "dailyChannel": "Wähle einen Kanal, in dem du tägliche Nachrichten haben möchtest!", @@ -247,6 +248,7 @@ "premium": "Um auf diese Funktion zuzugreifen, musst du ein [Would You Premium](https://wouldyoubot.gg/premium) Abo abschließen", "invalidLink": "Bitte gib einen gültigen PNG, JPG (JPEG), WEBP oder GIF Discord Anhang an, um ihn als Avatar des Bots festzulegen.", "daysSelection": "Wähle jeden Tag aus, an dem du **nicht** möchtest, dass tägliche Nachrichten gesendet werden.", + "customPerm": "Wählen Sie eine Rolle aus, die für das Hinzufügen benutzerdefinierter Fragen verwendet werden soll.", "embed": { "welcomeMessage": "**Willkommensnachricht**", "generalTitle": "Would You - Generelle Einstellungen", @@ -298,6 +300,7 @@ "username": "<:crown:1256988872160710808> **QOTD Nutzername**", "avatar": "<:crown:1256988872160710808> **QOTD Profilbild**", "classicMode": "**Klassik Modus **", + "customPerm": "**Benutzerdefinierte Berechtigungsrolle**", "noChannel": "Keine spezifischen Kanaleinstellungen", "globalType": "**Globaler Fragentyp**:", "channelType": "**Einstellungen pro Kanal**:" @@ -361,6 +364,7 @@ "globalType": "Globalen Fragentyp setzen", "channelType": "Per-Channel-Typen konfigurieren", "setGlobal": "Klicke auf den Typ, den du global setzen möchten.", + "customPerm": "Benutzerdefinierte Berechtigungsrolle festlegen", "setChannel": "Wähle einen Kanal aus, dem du einen Fragentyp hinzufügen möchten.", "typeRegex": "Du musst einen gültigen Typ angeben: `regular`, `custom` oder `mixed`." }, diff --git a/src/languages/en_EN.json b/src/languages/en_EN.json index a86997d9..05fe04ae 100644 --- a/src/languages/en_EN.json +++ b/src/languages/en_EN.json @@ -18,7 +18,8 @@ }, "Language": { "embed": { - "error": "You are missing the `Manage Guild` permission to use this command!", + "error": "You are missing the `Manage Guild` permission to use this command.", + "errorRole": "You need to have the role **{role}** to use this command!", "footer": "Would You" } }, @@ -225,7 +226,7 @@ }, "Settings": { "errorSame": "The provided timezone is the same timezone that is already set. Make sure to choose a different timezone.", - "errorInvalid": "Provided timezone was invalid, you can pick a valid timezone from this [Time Zone Picker](https://kevinnovak.github.io/Time-Zone-Picker/)", + "errorInvalid": "Provided timezone was invalid, you can pick a valid timezone from this [Time Zone Picker](https://zones.arilyn.cc/)", "intervalSame": "The provided post time is the same post time that is already set. Make sure to choose a different post time.", "intervalInvalid": "The provided post time was invalid. Make sure your post time is in the 24h format and minutes are either 00 or an interval of 5!", "dailyChannel": "Select a channel where you want Daily Messages to be!", @@ -247,6 +248,7 @@ "premium": "To access this feature you will need to subscribe to [Would You Premium](https://wouldyoubot.gg/premium)", "invalidLink": "Please provide a valid PNG, JPG (JPEG), WEBP or GIF Discord attachment to set as the bot's avatar.", "daysSelection": "Select every day you **don't** want daily messages to be on.", + "customPerm": "Select a role that will be used for adding custom questions.", "embed": { "generalTitle": "Would You - General Settings", "utilityTitle": "Would You - Utility Settings", @@ -297,7 +299,8 @@ "error": "You are missing the `Manage Guild` permission to use this command!", "username": "<:crown:1256988872160710808> **QOTD Username**", "avatar": "<:crown:1256988872160710808> **QOTD Avatar**", - "classicMode": "**Classic Mode **", + "classicMode": "**Classic Mode**", + "customPerm": "**Custom Permission Role**", "noChannel": "No specific channel settings", "globalType": "**Global Question Type**:", "channelType": "**Per-Channel Settings**:" @@ -362,6 +365,7 @@ "channelType": "Configure Per-Channel Types", "setGlobal": "Click on the type you want to set globally.", "setChannel": "Select a channel you want to add a question type to.", + "customPerm": "Set Custom Permission Role", "typeRegex": "You must provide a valid type: `regular`, `custom`, or `mixed`." }, "modal": { diff --git a/src/languages/es_ES.json b/src/languages/es_ES.json index 77d846fa..3ed52245 100644 --- a/src/languages/es_ES.json +++ b/src/languages/es_ES.json @@ -19,6 +19,7 @@ "Language": { "embed": { "error": "¡Te falta el permiso `Manage guild` para usar este comando!", + "errorRole": "¡Necesitas tener el rol **{role}** para usar este comando!", "footer": "Would You" } }, @@ -225,7 +226,7 @@ }, "Settings": { "errorSame": "La zona horaria proporcionada es la misma zona horaria que ya está definida. Asegúrese de elegir una zona horaria diferente.", - "errorInvalid": "La zona horaria proporcionada no es válida, puedes elegir una zona horaria válida aquí: [Selector de Zona Horaria](https://kevinnovak.github.io/Time-Zone-Picker/)", + "errorInvalid": "La zona horaria proporcionada no es válida, puedes elegir una zona horaria válida aquí: [Selector de Zona Horaria](https://zones.arilyn.cc/)", "intervalSame": "La hora de publicación especificada es la misma que la ya establecida. Asegúrese de elegir una hora de publicación diferente.", "intervalInvalid": "La hora del mensaje no es válida. ¡Asegúrese de que la hora del mensaje está en formato de 24 horas y de que los minutos son 00 o un intervalo de 5!", "dailyChannel": "¡Selecciona un canal donde quieres que sean enviados los Mensajes Diarios!", @@ -247,6 +248,7 @@ "premium": "Para acceder a esta función deberá suscribirse a [Would You Premium](https://wouldyoubot.gg/premium)", "invalidLink": "Proporciona un archivo adjunto válido PNG, JPG (JPEG), WEBP o GIF de Discord para establecerlo como avatar del bot.", "daysSelection": "Seleccione todos los días en los que **no** desea que aparezcan los mensajes diarios.", + "customPerm": "Seleccione el rol que se utilizará para añadir preguntas personalizadas.", "embed": { "welcomeMessage": "**Mensaje de bienvenida**", "generalTitle": "Would You - Configuración general", @@ -294,7 +296,8 @@ "error": "¡Te falta el permiso `Manage guild` para usar este comando!", "username": "<:crown:1256988872160710808> **QOTD Username**", "avatar": "<:crown:1256988872160710808> **QOTD Avatar**", - "classicMode": "**Modo Clásico**" + "classicMode": "**Modo Clásico**", + "customPerm": "**Rol de permiso personalizado**" }, "button": { "welcomeMessage": "Editar el mensaje de bienvenida", @@ -351,6 +354,7 @@ "welcomeEmbedTimestampMenu": "Borrar marca de tiempo", "avatar": "Establecer avatar", "name": "Establecer nombre de usuario", + "customPerm": "Establecer función de permisos personalizada", "classicMode": "Activar el modo clásico" }, "modal": { diff --git a/src/languages/fr_FR.json b/src/languages/fr_FR.json index ed775fd3..747c85d0 100644 --- a/src/languages/fr_FR.json +++ b/src/languages/fr_FR.json @@ -19,6 +19,7 @@ "Language": { "embed": { "error": "Vous avez besoin de la permission `Gérer le serveur` pour utiliser cette commande !", + "errorRole": "Vous devez avoir le rôle **{role}** pour utiliser cette commande !", "footer": "Would You" } }, @@ -225,7 +226,7 @@ }, "Settings": { "errorSame": "Le fuseau horaire fourni est le même fuseau horaire que celui déjà défini. Assurez-vous de choisir un autre fuseau horaire.", - "errorInvalid": "Le fuseau horaire fourni est invalide, vous pouvez choisir un fuseau horaire valide sur ce [sélecteur de fuseau horaire](https://kevinnovak.github.io/Time-Zone-Picker/)", + "errorInvalid": "Le fuseau horaire fourni est invalide, vous pouvez choisir un fuseau horaire valide sur ce [sélecteur de fuseau horaire](https://zones.arilyn.cc/)", "intervalSame": "L'heure de publication indiquée est la même que celle déjà définie. Assure-toi de choisir une autre heure de publication.", "intervalInvalid": "L'heure de publication fournie n'est pas valide. Assure-toi que ton heure d'envoi est au format 24h et que les minutes sont soit 00, soit un multiple de 5 !", "dailyChannel": "Sélectionnez le channel où vous voulez que les messages quotidiens soient postés !", @@ -247,6 +248,7 @@ "premium": "Pour accéder à cette fonctionnalité, vous devrez vous abonner à [Would You Premium](https://wouldyoubot.gg/premium)", "invalidLink": "Veuillez fournir une pièce jointe Discord valide PNG, JPG (JPEG), WEBP ou GIF à définir comme avatar du bot.", "daysSelection": "Sélectionnez chaque jour que vous **ne voulez pas** que les messages quotidiens soient allumés.", + "customPerm": "Sélectionnez un rôle qui sera utilisé pour ajouter des questions personnalisées.", "embed": { "welcomeMessage": "**Message de bienvenue**", "generalTitle": "Would You - Paramètres généraux", @@ -294,7 +296,8 @@ "error": "Vous avez besoin de la permission `Gérer le serveur` pour utiliser cette commande!", "username": "<:crown:1256988872160710808> **Nom d'utilisateur QOTD**", "avatar": "<:crown:1256988872160710808> **Avatar QOTD**", - "classicMode": "**Mode classique**" + "classicMode": "**Mode classique**", + "customPerm": "**Rôle de permission personnalisé**" }, "button": { "welcomeMessage": "Modifier le message de bienvenue", @@ -351,6 +354,7 @@ "welcomeEmbed": "Retour", "avatar": "Définir l'avatar", "name": "Définir le nom d'utilisateur", + "customPerm": "Définir un rôle d'autorisation personnalisé", "classicMode": "Activer/désactiver le mode classique" }, "modal": { diff --git a/src/languages/it_IT.json b/src/languages/it_IT.json index 896833ca..b25b0fbe 100644 --- a/src/languages/it_IT.json +++ b/src/languages/it_IT.json @@ -19,6 +19,7 @@ "Language": { "embed": { "error": "Hai bisogno del permesso `Gestire Server` per usare questo comando!", + "errorRole": "Per utilizzare questo comando è necessario avere il ruolo **{role}**!", "footer": "Would You" } }, @@ -225,7 +226,7 @@ }, "Settings": { "errorSame": "Il fuso orario selezionato è lo stesso già impostato. Assicurati di scegliere un fuso orario diverso.", - "errorInvalid": "Il fuso orario fornito non è valido, puoi sceglierne uno da questa [Lista di Fusi Orari](https://kevinnovak.github.io/Time-Zone-Picker/)", + "errorInvalid": "Il fuso orario fornito non è valido, puoi sceglierne uno da questa [Lista di Fusi Orari](https://zones.arilyn.cc/)", "intervalSame": "L'orario di pubblicazione selezionato è lo stesso già impostato. Assicurati di scegliere un orario diverso.", "intervalInvalid": "L'orario del messaggio fornito non è valido. Assicurati che l'ora di invio sia nel formato 24h e che i minuti siano 00 o un intervallo di 5!", "dailyChannel": "Seleziona il canale dove vuoi che vengano inviati i Messaggi Giornalieri!", @@ -247,6 +248,7 @@ "premium": "Per accedere a questa funzionalità dovrai iscriverti a [Would You Premium](https://wouldyoubot.gg/premium)", "invalidLink": "Fornisci un valido allegato PNG, JPG (JPEG), WEBP o GIF Discord da impostare come avatar del bot.", "daysSelection": "Seleziona ogni giorno che **non** vuoi che i messaggi giornalieri siano attivi.", + "customPerm": "Selezionare un ruolo da utilizzare per l'aggiunta di domande personalizzate.", "embed": { "welcomeMessage": "**Messaggio di benvenuto**", "generalTitle": "Would You - Impostazioni generali", @@ -294,7 +296,8 @@ "error": "Hai bisogno del permesso `Gestire Server` per usare questo comando!", "username": "<:crown:1256988872160710808> **Nome Utente QOTD**", "avatar": "<:crown:1256988872160710808> **QOTD Avatar**", - "classicMode": "**Modalità classica **" + "classicMode": "**Modalità classica **", + "customPerm": "**Ruolo di autorizzazione personalizzato**" }, "button": { "welcomeMessage": "Modifica del messaggio di benvenuto", @@ -351,6 +354,7 @@ "welcomeEmbedTimestampMenu": "Cancellare il timestamp", "avatar": "Imposta Avatar", "name": "Imposta Nome Utente", + "customPerm": "Impostare il ruolo di autorizzazione personalizzato", "classicMode": "Alterna la modalità classica" }, "modal": { diff --git a/src/util/Functions/fileToCollection.ts b/src/util/Functions/fileToCollection.ts index 932d5c9c..e7ba218f 100644 --- a/src/util/Functions/fileToCollection.ts +++ b/src/util/Functions/fileToCollection.ts @@ -16,16 +16,18 @@ export async function fileToCollection< if (dirent.isDirectory()) { processDirectory(fullPath); } else if (dirent.isFile() && dirent.name.endsWith(".js")) { - const importPromise = import(fullPath).then((resp: { default: Type }) => { - const key = getKey(resp.default); - if (key) { - collection.set(key, resp.default); - } else { - console.warn(`Could not determine key for file: ${fullPath}`); - } - }).catch(error => { - console.error(`Error importing file ${fullPath}:`, error); - }); + const importPromise = import(fullPath) + .then((resp: { default: Type }) => { + const key = getKey(resp.default); + if (key) { + collection.set(key, resp.default); + } else { + console.warn(`Could not determine key for file: ${fullPath}`); + } + }) + .catch((error) => { + console.error(`Error importing file ${fullPath}:`, error); + }); promises.push(importPromise); } } diff --git a/src/util/Functions/jsonImport.ts b/src/util/Functions/jsonImport.ts index accc1d60..f82b5446 100644 --- a/src/util/Functions/jsonImport.ts +++ b/src/util/Functions/jsonImport.ts @@ -100,7 +100,7 @@ export async function getRandomTod( guildDb: IGuildModel, language: string, premium: boolean, - enabled = true + enabled = true, ): Promise { const truth = await getQuestionsByType( channel, @@ -108,7 +108,7 @@ export async function getRandomTod( guildDb, language, premium, - enabled + enabled, ); const dare = await getQuestionsByType( channel, @@ -116,7 +116,7 @@ export async function getRandomTod( guildDb, language, premium, - enabled + enabled, ); return Math.random() < 0.5 ? truth : dare; @@ -128,7 +128,7 @@ export async function getQuestionsByType( guildDb: IGuildModel, language: string, premium: boolean, - enabled = true + enabled = true, ): Promise { if (!validTypes.includes(type)) { return Promise.reject("Invalid type"); @@ -144,7 +144,7 @@ export async function getQuestionsByType( topic: topicModel, }; - let selectedModel = models[type.toLowerCase()]; + const selectedModel = models[type.toLowerCase()]; let result: QuestionResult = { id: "", question: "" }; @@ -172,6 +172,8 @@ export async function getQuestionsByType( customWwydQuestions: [], wyrQuestions: [], customWyrQuestions: [], + topicQuestions: [], + customTopicQuestions: [], }); usedQuestions = await usedQuestionModel.find({ @@ -186,28 +188,38 @@ export async function getQuestionsByType( ]); } - let questionDatabase = await getDBQuestion( - premium && enabled ? usedQuestions[0][typeCheck[type]] : [] - ); - - if (!questionDatabase[0]?.id && premium && enabled) { - await reset(type as Quest, guildDb.customTypes, guildDb.guildID, "db"); - questionDatabase = await getDBQuestion([]); + interface QuestionData { + id: string; + question: string; + translations?: { [key: string]: string }; + type?: string; } async function getRandomCustom(nin: string[]) { - return await GuildModel.aggregate([ + const customCount = await GuildModel.aggregate([ { $match: { guildID: guildDb.guildID } }, { $unwind: "$customMessages" }, { $match: { - "customMessages.id": { - $nin: nin, - }, "customMessages.type": type === "whatwouldyoudo" ? "wwyd" : type, }, }, - { $sample: { size: 1 } }, + { $count: "total" }, + ]); + + if (!customCount[0]?.total) { + return null; + } + + const availableCustomQuestions = await GuildModel.aggregate([ + { $match: { guildID: guildDb.guildID } }, + { $unwind: "$customMessages" }, + { + $match: { + "customMessages.type": type === "whatwouldyoudo" ? "wwyd" : type, + "customMessages.id": { $nin: nin }, + }, + }, { $project: { id: "$customMessages.id", @@ -216,20 +228,96 @@ export async function getQuestionsByType( }, }, ]); + + if (availableCustomQuestions.length === 0) { + await reset(type as Quest, "custom", guildDb.guildID, "custom"); + + const allCustomQuestions = await GuildModel.aggregate([ + { $match: { guildID: guildDb.guildID } }, + { $unwind: "$customMessages" }, + { + $match: { + "customMessages.type": type === "whatwouldyoudo" ? "wwyd" : type, + }, + }, + { + $project: { + id: "$customMessages.id", + question: "$customMessages.question", + type: "$customMessages.type", + }, + }, + ]); + + const randomIndex = Math.floor( + Math.random() * allCustomQuestions.length, + ); + return [allCustomQuestions[randomIndex]]; + } + + const randomIndex = Math.floor( + Math.random() * availableCustomQuestions.length, + ); + return [availableCustomQuestions[randomIndex]]; } - let newRandomCustomQuestion = await getRandomCustom( - premium && enabled ? usedQuestions[0][typeCheck[`custom${type}`]] : [] + const hasCustomQuestions = await GuildModel.aggregate([ + { $match: { guildID: guildDb.guildID } }, + { $unwind: "$customMessages" }, + { + $match: { + "customMessages.type": type === "whatwouldyoudo" ? "wwyd" : type, + }, + }, + { $count: "total" }, + ]); + + if (hasCustomQuestions[0]?.total > 0) { + const customQuestion = await getRandomCustom( + premium && enabled + ? usedQuestions[0]?.[typeCheck[`custom${type}`]] || [] + : [], + ); + + if (!customQuestion?.[0]) { + return Promise.reject("Error getting custom question"); + } + + if (premium && enabled) { + await usedQuestionModel.updateOne( + { guildID: guildDb.guildID }, + { $push: { [typeCheck[`custom${type}`]]: customQuestion[0].id } }, + ); + } + + return { + id: customQuestion[0].id, + question: customQuestion[0].question, + }; + } + + // Only get normal questions if there are no custom questions configured + let questionDatabase = await getDBQuestion( + premium && enabled ? usedQuestions[0]?.[typeCheck[type]] || [] : [], ); - if (!newRandomCustomQuestion[0]?.id && premium && enabled) { - await reset( - type as Quest, - guildDb.customTypes, - guildDb.guildID, - "custom" + if (!questionDatabase[0]?.id && premium && enabled) { + await reset(type as Quest, "regular", guildDb.guildID, "db"); + questionDatabase = await getDBQuestion([]); + } + + if (!questionDatabase[0]) { + return Promise.reject("No questions available"); + } + + const dbQuestion = questionDatabase[0] as QuestionData; + + // Track the used normal question for premium users + if (premium && enabled) { + await usedQuestionModel.updateOne( + { guildID: guildDb.guildID }, + { $push: { [typeCheck[type]]: dbQuestion.id } }, ); - newRandomCustomQuestion = await getRandomCustom([]); } let types = @@ -243,56 +331,46 @@ export async function getQuestionsByType( switch (types) { case "regular": result = { - id: questionDatabase[0].id, + id: dbQuestion.id, question: normalizedLanguage === "en_EN" - ? questionDatabase[0].question - : questionDatabase[0].translations[normalizedLanguage], + ? dbQuestion.question + : dbQuestion.translations?.[normalizedLanguage] || + dbQuestion.question, }; - break; case "mixed": { - const mixedQuestions = shuffle([ - ...questionDatabase.concat(newRandomCustomQuestion[0]), - ]); + const availableQuestions = questionDatabase.map( + (q: any) => ({ ...q }) as QuestionData, + ); + const mixedQuestions = shuffle(availableQuestions); + const question = mixedQuestions[0] as QuestionData; + + if (!question) { + return Promise.reject("No questions available"); + } - const question = mixedQuestions[0] - ? mixedQuestions[0] - : mixedQuestions[1]; - result = { - id: question?.id, + id: question.id, question: normalizedLanguage === "en_EN" - ? question?.question - : question?.translations?.[normalizedLanguage] || - question?.question, + ? question.question + : question.translations?.[normalizedLanguage] || + question.question, }; break; } case "custom": result = { - id: newRandomCustomQuestion[0].id, - question: newRandomCustomQuestion[0].question, + id: dbQuestion.id, + question: + normalizedLanguage === "en_EN" + ? dbQuestion.question + : dbQuestion.translations?.[normalizedLanguage] || + dbQuestion.question, }; break; } - - if (premium && enabled) { - if (types === "custom") { - selectedModel = typeCheck[`custom${type}`]; - } else if (types === "mixed") { - if (result.id === questionDatabase[0].id) - selectedModel = typeCheck[type]; - else selectedModel = typeCheck[`custom${type}`]; - } else { - selectedModel = typeCheck[type]; - } - await usedQuestionModel.updateOne( - { guildID: guildDb.guildID }, - { $push: { [selectedModel]: result.id } } - ); - } } else { const questionDatabase = await selectedModel.aggregate([ { $sample: { size: 1 } }, @@ -314,7 +392,7 @@ export async function reset( type: Quest, customType: string, guildID: string, - resetType: string + resetType: string, ): Promise { let selectedModel: string; if (customType === "custom") { @@ -332,6 +410,6 @@ export async function reset( $set: { [selectedModel]: [], }, - } + }, ); } diff --git a/src/util/Models/guildModel.ts b/src/util/Models/guildModel.ts index 03b436ee..9d00aa8e 100644 --- a/src/util/Models/guildModel.ts +++ b/src/util/Models/guildModel.ts @@ -66,6 +66,8 @@ export interface IGuildModel { commandCooldown: number; commandBy: string; commandType: string; + customPerm: string | null; + dmsError?: string | null; } const guildProfileSchema = new Schema( @@ -172,7 +174,7 @@ const guildProfileSchema = new Schema( }, dailyQuestionType: { type: [String], - default: ['wyrModel', 'wwydModel', 'nhieModel'], + default: ["wyrModel", "wwydModel", "nhieModel"], }, dailyTimezone: { type: String, @@ -285,11 +287,19 @@ const guildProfileSchema = new Schema( type: String, default: "Command", }, + customPerm: { + type: String, + default: null, + }, + dmsError: { + type: String, + default: null, + }, }, - { timestamps: true } + { timestamps: true }, ); export const GuildModel = model( "guildProfile", - guildProfileSchema + guildProfileSchema, ); diff --git a/src/util/Models/zod/welcomeEmbed.ts b/src/util/Models/zod/welcomeEmbed.ts index aea90f00..927633ea 100644 --- a/src/util/Models/zod/welcomeEmbed.ts +++ b/src/util/Models/zod/welcomeEmbed.ts @@ -10,7 +10,7 @@ const welcomeEmbedSchema = z.object({ description: z .string() .min(3, "Make sure your description is at least 3 characters long") - .max(350, "Make sure your description is only 150 characters long"), + .max(1000, "Make sure your description is only 1000 characters long"), author: z.object({ name: z .string() @@ -18,14 +18,18 @@ const welcomeEmbedSchema = z.object({ .max(100, "Make sure your author name is only 100 characters long"), url: z.string().url(), }), - thumbnail: z.union([ - z.string().url(), - z.enum(['{{user_avatarUrl}}', '{{guild_iconUrl}}']) - ]).optional(), - image: z.union([ - z.string().url(), - z.enum(['{{user_avatarUrl}}', '{{guild_iconUrl}}']) - ]).optional(), + thumbnail: z + .union([ + z.string().url(), + z.enum(["{{user_avatarUrl}}", "{{guild_iconUrl}}"]), + ]) + .optional(), + image: z + .union([ + z.string().url(), + z.enum(["{{user_avatarUrl}}", "{{guild_iconUrl}}"]), + ]) + .optional(), footer: z.object({ text: z .string() @@ -33,7 +37,7 @@ const welcomeEmbedSchema = z.object({ .max(100, "Make sure your footer text is only 100 characters long"), iconURL: z.union([ z.string().url(), - z.enum(['{{user_avatarUrl}}', '{{guild_iconUrl}}']) + z.enum(["{{user_avatarUrl}}", "{{guild_iconUrl}}"]), ]), }), color: z diff --git a/src/util/dailyMessage.ts b/src/util/dailyMessage.ts index 2d08ba14..2ac9a27c 100644 --- a/src/util/dailyMessage.ts +++ b/src/util/dailyMessage.ts @@ -15,12 +15,12 @@ export default class DailyMessage { * Start the daily message Schedule */ async listen() { - let username = process.env.RABBITMQ_DEFAULT_USER || "" - let password = process.env.RABBITMQ_DEFAULT_PASS || "" - username = encodeURIComponent(username) - password = encodeURIComponent(password) + let username = process.env.RABBITMQ_DEFAULT_USER!; + let password = process.env.RABBITMQ_DEFAULT_PASS!; + username = encodeURIComponent(username); + password = encodeURIComponent(password); - let URI = process.env.RABBITMQ_URL || "fallback"; + const URI = process.env.RABBITMQ_URL!; const connection = await amqplib.connect(URI, { clientProperties: { connection_name: `client-cluster-${this.client.cluster.id}`, @@ -211,12 +211,15 @@ export default class DailyMessage { type: string, qid: string, ): EmbedBuilder { + console.log( + `Building embed for daily message: ${question} | ID: ${id} | Type: ${type} | QID: ${qid}`, + ); return new EmbedBuilder() .setColor("#0598F6") .setFooter({ text: `Daily Message | Type: ${type.replace(/^\w/, (content) => content.toUpperCase(), - )} | ID: ${id} QID: ${qid}`, + )} | ID: ${id}`, }) .setDescription(bold(question) as string); } diff --git a/src/util/keepAlive.ts b/src/util/keepAlive.ts index 674bc5af..73ea6203 100644 --- a/src/util/keepAlive.ts +++ b/src/util/keepAlive.ts @@ -16,10 +16,10 @@ export default class KeepAlive { this.client.rest.on("rateLimited", (log) => { const { route: path, limit, timeToReset: timeout } = log; captureMessage( - `Rate limited on ${path} with a limit of ${limit} and a timeout of ${timeout}` + `Rate limited on ${path} with a limit of ${limit} and a timeout of ${timeout}`, ); captureMessage( - `Rate limited on ${path} with a limit of ${limit} and a timeout of ${timeout}` + `Rate limited on ${path} with a limit of ${limit} and a timeout of ${timeout}`, ); }); diff --git a/src/util/wouldYou.ts b/src/util/wouldYou.ts index db9fb6b6..3f8adb1f 100644 --- a/src/util/wouldYou.ts +++ b/src/util/wouldYou.ts @@ -132,9 +132,9 @@ export default class WouldYou extends Client { this.keepAlive = new KeepAlive(this); this.keepAlive.start(); - // Daily Message - this.dailyMessage = new DailyMessage(this); - this.dailyMessage.listen(); + // Daily Message - Turned off as DMS runs by itself now + // this.dailyMessage = new DailyMessage(this); + // this.dailyMessage.listen(); this.voting = new Voting(this);