fix: fix/archive #56

Merged
loonatiny merged 9 commits from fix/archive into main 2023-01-17 22:05:39 +01:00
2 changed files with 11 additions and 13 deletions
Showing only changes of commit e69f67f6d3 - Show all commits

View file

@ -1,8 +1,8 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { ChannelType, Client, CommandInteraction, EmbedBuilder } from 'discord.js';
import '../../modules/string';
import { getLocale, getLocalizations } from '../../utils/locales';
import { getFilename } from '../../utils/misc';
import '../../modules/string';
export default {
data: (client: Client) => {
@ -52,10 +52,10 @@ export default {
}
// If a category is specified
const clean_cat = ['L1', 'L2', 'L3', 'M1', 'M2'];
const channel = clean_cat.includes(desired_cat);
const allowedCategories = ['L1', 'L2', 'L3', 'M1', 'M2'];
const channel = allowedCategories.includes(desired_cat);
if (!channel) {
// Category doesn't exist or is not included
// Category doesn't exist or is not allowed
return interaction.reply({
content: `${loc.get('c_prep3')} \`${desired_cat}\``,
ephemeral: true,
@ -65,13 +65,13 @@ export default {
// 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);
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);
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 = '';
@ -106,8 +106,6 @@ export default {
.setColor('Blurple')
.setTitle(loc.get('c_prep4') + cat_to_prep_name)
.setDescription(
// Loads the description
// according to the user's locals
desc,
),
],

View file

@ -23,8 +23,8 @@
"c_archive1": "Liste des catégories soumis au nettoyage",
"c_archive2": "`L1`, `L2`, `L3`, `M1`, `M2`",
"c_archive3": "Impossible de trouver/nettoyer le salon :",
"c_archive4": "Listes des Salons archivés de la catégorie `",
"c_archive5": "` vers `",
"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",