From db7dd69de69598d37a8d1816823e5fa4d559ca8b Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 4 Sep 2024 09:25:41 +0200 Subject: [PATCH 1/2] remove archive related commands --- src/commands/misc/archive.ts | 139 ----------------------------------- src/commands/misc/prep.ts | 118 ----------------------------- 2 files changed, 257 deletions(-) delete mode 100644 src/commands/misc/archive.ts delete mode 100644 src/commands/misc/prep.ts diff --git a/src/commands/misc/archive.ts b/src/commands/misc/archive.ts deleted file mode 100644 index 2fa4bdf..0000000 --- a/src/commands/misc/archive.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { SlashCommandBuilder } from "@discordjs/builders"; -import { - ChannelType, - Client, - Colors, - CommandInteraction, - EmbedBuilder, - NonThreadGuildBasedChannel, -} from "discord.js"; -import "../../modules/string"; -import { getLocale, getLocalizations } from "../../utils/locales"; -import { getFilename } from "../../utils/misc"; - -export default { - scope: () => ["807244911350906920"], - - data: (client: Client) => { - const filename = getFilename(__filename); - return ( - new SlashCommandBuilder() - .setName(filename.toLowerCase()) - .setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!) - .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) - .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) - - // Command option - .addStringOption((option) => - option - .setName( - client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_name`)!, - ) - .setDescription( - client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_desc`)!, - ) - .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) - .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), - ) - ); - }, - - interaction: async (interaction: CommandInteraction, client: Client) => { - const loc = getLocale(client, interaction.locale); - const desiredCat = interaction.options.get( - client.locales - .get(client.config.default_lang)! - .get(`c_${getFilename(__filename)}_opt1_name`)!, - )?.value as string; - - // If a category isn't specified - if (!desiredCat) { - // Sends a list of commands sorted into categories - return interaction.reply({ - embeds: [ - new EmbedBuilder() - .setColor(Colors.Blurple) - .setTitle(loc.get("c_archive1")) - .setDescription(loc.get("c_archive2")), - ], - }); - } - - // If a category is specified - const cleanCat = ["L1", "L2", "L3", "M1", "M2"]; - const channel = cleanCat.includes(desiredCat); - if (!channel) { - // Category doesn't exist or is not included - return interaction.reply({ - content: `${loc.get("c_archive3")} \`${desiredCat}\``, - ephemeral: true, - }); - } - - const allChannel = interaction.guild?.channels.fetch(); - allChannel?.then(async (channelGuild) => { - // Retrieve category to archive - const catToArchive = channelGuild - .filter((chan) => chan?.type == ChannelType.GuildCategory) - .filter((chan) => chan?.name == desiredCat); - - // Create/Retrieve the archive category - const catArchivedName = "archive - " + desiredCat; - const catArchivedMap = channelGuild - .filter((chan) => chan?.type == ChannelType.GuildCategory) - .filter((chan) => chan?.name == catArchivedName); - - let catArchived: NonThreadGuildBasedChannel | null | undefined; - if (catArchivedMap.size > 0) { - catArchived = catArchivedMap.at(0); - } else { - catArchived = await interaction.guild?.channels.create({ - name: catArchivedName, - type: ChannelType.GuildCategory, - }); - } - - const allChannelDesired = channelGuild - .filter((chan) => chan?.type == 0) - .filter((chan) => chan?.parentId == catToArchive.map((cat) => cat?.id)[0]); - - // If no channels in the source category - if (allChannelDesired.size == 0) { - return interaction.reply({ - embeds: [ - new EmbedBuilder() - .setColor(Colors.Blurple) - .setTitle(loc.get("c_archive6")) - .setDescription(loc.get("c_archive7")), - ], - }); - } - - // Move channels to the archived categoryx - allChannelDesired.forEach((elem) => elem?.setParent(catArchived?.id as string)); - - return interaction.reply({ - embeds: [ - new EmbedBuilder() - .setColor(Colors.Blurple) - .setTitle( - loc.get("c_archive4") + - " `" + - catToArchive.map((cat) => cat?.name) + - "` " + - loc.get("c_archive5") + - " `" + - catArchivedName + - "`", - ) - .setDescription( - allChannelDesired - .map((cgD) => cgD?.name) - .toString() - .replaceAll(",", "\n"), - ), - ], - }); - }); - }, -}; diff --git a/src/commands/misc/prep.ts b/src/commands/misc/prep.ts deleted file mode 100644 index fa4ab30..0000000 --- a/src/commands/misc/prep.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { SlashCommandBuilder } from "@discordjs/builders"; -import { ChannelType, Client, Colors, CommandInteraction, EmbedBuilder } from "discord.js"; -import "../../modules/string"; -import { getLocale, getLocalizations } from "../../utils/locales"; -import { getFilename } from "../../utils/misc"; - -export default { - scope: () => ["807244911350906920"], - - data: (client: Client) => { - const filename = getFilename(__filename); - return ( - new SlashCommandBuilder() - .setName(filename.toLowerCase()) - .setDescription(client.locales.get(client.config.default_lang)!.get(`c_${filename}_desc`)!) - .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) - .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) - - // Command option - .addStringOption((option) => - option - .setName( - client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_name`)!, - ) - .setDescription( - client.locales.get(client.config.default_lang)!.get(`c_${filename}_opt1_desc`)!, - ) - .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) - .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)), - ) - ); - }, - - interaction: async (interaction: CommandInteraction, client: Client) => { - const loc = getLocale(client, interaction.locale); - const desired_cat = interaction.options.get( - client.locales - .get(client.config.default_lang)! - .get(`c_${getFilename(__filename)}_opt1_name`)!, - )?.value as string; - - // If a category isn't specified - if (!desired_cat) { - // Sends a list of commands sorted into categories - return interaction.reply({ - embeds: [ - new EmbedBuilder() - .setColor(Colors.Blurple) - .setTitle(loc.get("c_prep1")) - .setDescription(loc.get("c_prep2")), - ], - }); - } - - // If a category is specified - const allowedCategories = ["L1", "L2", "L3", "M1", "M2"]; - const channel = allowedCategories.includes(desired_cat); - if (!channel) { - // Category doesn't exist or is not allowed - return interaction.reply({ - content: `${loc.get("c_prep3")} \`${desired_cat}\``, - ephemeral: true, - }); - } - - // Send information about the command - const allChannel = interaction.guild?.channels.fetch(); - allChannel?.then((channel_guild) => { - const cat_to_prep = channel_guild - .filter((chan) => chan?.type == ChannelType.GuildCategory) - .filter((chan) => chan?.name == desired_cat); - const cat_to_prep_id = cat_to_prep.map((cat) => cat?.id); - const cat_to_prep_name = cat_to_prep.map((cat) => cat?.name); - - // console.log(cat_to_prep); - const all_channel_desired = channel_guild - .filter((chan) => chan?.type == 0) - .filter((chan) => chan?.parentId == cat_to_prep_id[0]); - const all_channel_desired_name = all_channel_desired.map((c_d) => c_d?.name); - - let desc = ""; - - const general = "général"; - if (all_channel_desired_name.filter((cdn) => cdn == general).length == 0) { - interaction.guild?.channels.create({ - name: general, - type: 0, - parent: cat_to_prep_id[0], - }); - desc = general + loc.get("c_prep5") + "\n"; - } - - const info = "informations"; - if (all_channel_desired_name.filter((cdn) => cdn == info).length == 0) { - interaction.guild?.channels.create({ - name: info, - type: 0, - parent: cat_to_prep_id[0], - }); - - desc += "`" + info + "` " + loc.get("c_prep5") + "\n"; - } - - if (desc == "") { - desc = loc.get("c_prep6"); - } - - return interaction.reply({ - embeds: [ - new EmbedBuilder() - .setColor(Colors.Blurple) - .setTitle(loc.get("c_prep4") + cat_to_prep_name) - .setDescription(desc), - ], - }); - }); - }, -}; -- 2.45.2 From 10fa6117405123f82c01f524be94359c12b762eb Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 17 Sep 2024 19:35:42 +0200 Subject: [PATCH 2/2] remove translations --- src/locales/en-US.json | 23 ----------------------- src/locales/fr.json | 23 ----------------------- 2 files changed, 46 deletions(-) diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 807ac06..dde818c 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -17,29 +17,6 @@ "c_help2": "`/help ` to get more information about a command.", "c_help3": "Can't find :", - "c_archive_name": "clean", - "c_archive_desc": "Clean category for the new year", - "c_archive_opt1_name": "category", - "c_archive_opt1_desc": "Name of the category to be cleaned", - "c_archive1": "List of categories subject to cleaning", - "c_archive2": "`L1`, `L2`, `L3`, `M1`, `M2`", - "c_archive3": "Unable to find/clean the channel:", - "c_archive4": "List of archived channels in the category", - "c_archive5": "to", - "c_archive6": "Cleaning", - "c_archive7": "Category already cleaned", - - "c_prep_name": "Preparation", - "c_prep_desc": "Preparation of general channels for the new year", - "c_prep_opt1_name": "year", - "c_prep_opt1_desc": "Name of the year to be prepared", - "c_prep1": "List of categories submitted to the preparation", - "c_prep2": "`L1`, `L2`, `L3`, `M1`, `M2`", - "c_prep3": "Unable to find/clean the channel:", - "c_prep4": "Lists of prepared channels `", - "c_prep5": "created", - "c_prep6": "No preparation is required", - "u_time_at": "at", "c_reminder_name": "reminder", diff --git a/src/locales/fr.json b/src/locales/fr.json index 9354717..5664687 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -17,29 +17,6 @@ "c_help2": "`/help ` pour obtenir plus d'informations sur une commande.", "c_help3": "Impossible de trouver :", - "c_archive_name": "Nettoyer", - "c_archive_desc": "Nettoyage pour le passage à niveau", - "c_archive_opt1_name": "catégorie", - "c_archive_opt1_desc": "Nom de la catégorie à nettoyer", - "c_archive1": "Liste des catégories soumises au nettoyage", - "c_archive2": "`L1`, `L2`, `L3`, `M1`, `M2`", - "c_archive3": "Impossible de trouver/nettoyer le salon :", - "c_archive4": "Liste des salons archivés de la catégorie", - "c_archive5": "vers", - "c_archive6": "Nettoyage", - "c_archive7": "Catégorie déjà nettoyée", - - "c_prep_name": "Préparation", - "c_prep_desc": "Préparation des salons généraux pour la nouvelle année", - "c_prep_opt1_name": "année", - "c_prep_opt1_desc": "Nom de l'année à préparer", - "c_prep1": "Liste des catégories soumises à la préparation", - "c_prep2": "`L1`, `L2`, `L3`, `M1`, `M2`", - "c_prep3": "Impossible de trouver/nettoyer le salon :", - "c_prep4": "Listes des salons préparés `", - "c_prep5": "créé", - "c_prep6": "Pas besoin de préparation", - "u_time_at": "à", "c_reminder_name": "rappel", -- 2.45.2