refactor: typo

This commit is contained in:
Mylloon 2022-08-29 22:21:14 +02:00
parent 5d3b2638cc
commit 72b6c21a3c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 68 additions and 60 deletions

View file

@ -1,6 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders'; import { SlashCommandBuilder } from '@discordjs/builders';
import { Locale } from 'discord-api-types/v9'; import { ChannelType, Client, CommandInteraction, EmbedBuilder } from 'discord.js';
import { CategoryChannel, ChannelType, Client, CommandInteraction, EmbedBuilder, Guild } from 'discord.js';
import { getLocale, getLocalizations } from '../../utils/locales'; import { getLocale, getLocalizations } from '../../utils/locales';
import { getFilename } from '../../utils/misc'; import { getFilename } from '../../utils/misc';
import '../../modules/string'; import '../../modules/string';
@ -42,12 +41,14 @@ export default {
if (!desired_cat) { if (!desired_cat) {
// Sends a list of commands sorted into categories // Sends a list of commands sorted into categories
return interaction.reply({ embeds: [ return interaction.reply({
new EmbedBuilder() embeds: [
.setColor('Blurple') new EmbedBuilder()
.setTitle(loc.get('c_archive1')) .setColor('Blurple')
.setDescription(loc.get('c_archive2')), .setTitle(loc.get('c_archive1'))
] }); .setDescription(loc.get('c_archive2')),
],
});
} }
// If a category is specified // If a category is specified
@ -74,16 +75,18 @@ export default {
const all_channel_desired = channel_guild.filter(chan => chan.type == 0).filter(chan => chan.parentId == cat_to_archive_id[0]); const all_channel_desired = channel_guild.filter(chan => chan.type == 0).filter(chan => chan.parentId == cat_to_archive_id[0]);
if (all_channel_desired.size == 0) { if (all_channel_desired.size == 0) {
return interaction.reply({ embeds: [ return interaction.reply({
new EmbedBuilder() embeds: [
.setColor('Blurple') new EmbedBuilder()
.setTitle(loc.get('c_archive6')) .setColor('Blurple')
.setDescription( .setTitle(loc.get('c_archive6'))
// Loads the description .setDescription(
// according to the user's locals // Loads the description
'Catégorie déjà nettoyée' // according to the user's locals
), loc.get('c_archive7')
] }); ),
],
});
} }
const all_channel_desired_name = all_channel_desired.map(cg_d => cg_d.name); const all_channel_desired_name = all_channel_desired.map(cg_d => cg_d.name);
console.log(all_channel_desired_name); console.log(all_channel_desired_name);
@ -92,16 +95,18 @@ export default {
); );
const list_cg_moved = all_channel_desired_name.toString().replaceAll(',', '\n'); const list_cg_moved = all_channel_desired_name.toString().replaceAll(',', '\n');
return interaction.reply({ embeds: [ return interaction.reply({
new EmbedBuilder() embeds: [
.setColor('Blurple') new EmbedBuilder()
.setTitle(loc.get('c_archive4') + cat_to_archive_name + loc.get('c_archive5') + cat_archived_name + '`') .setColor('Blurple')
.setDescription( .setTitle(loc.get('c_archive4') + cat_to_archive_name + loc.get('c_archive5') + cat_archived_name + '`')
// Loads the description .setDescription(
// according to the user's locals // Loads the description
list_cg_moved // according to the user's locals
), list_cg_moved
] }); ),
],
});
}); });
}, },
}; };

View file

@ -1,6 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders'; import { SlashCommandBuilder } from '@discordjs/builders';
import { Locale } from 'discord-api-types/v9'; import { ChannelType, Client, CommandInteraction, EmbedBuilder } from 'discord.js';
import { CategoryChannel, ChannelType, Client, CommandInteraction, EmbedBuilder, Guild } from 'discord.js';
import { getLocale, getLocalizations } from '../../utils/locales'; import { getLocale, getLocalizations } from '../../utils/locales';
import { getFilename } from '../../utils/misc'; import { getFilename } from '../../utils/misc';
import '../../modules/string'; import '../../modules/string';
@ -42,12 +41,14 @@ export default {
if (!desired_cat) { if (!desired_cat) {
// Sends a list of commands sorted into categories // Sends a list of commands sorted into categories
return interaction.reply({ embeds: [ return interaction.reply({
new EmbedBuilder() embeds: [
.setColor('Blurple') new EmbedBuilder()
.setTitle(loc.get('c_prep1')) .setColor('Blurple')
.setDescription(loc.get('c_prep2')), .setTitle(loc.get('c_prep1'))
] }); .setDescription(loc.get('c_prep2')),
],
});
} }
// If a category is specified // If a category is specified
@ -68,50 +69,49 @@ export default {
const cat_to_prep_id = cat_to_prep.map(cat => cat.id); 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_name = cat_to_prep.map(cat => cat.name);
const cat_archived = channel_guild.filter(chan => chan.type == ChannelType.GuildCategory).filter(chan => chan.name == 'archive - ' + desired_cat);
const cat_archived_id = cat_archived.map(cat => cat.id);
const cat_archived_name = cat_archived.map(cat => cat.name);
// console.log(cat_to_prep); // 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 = 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_name = all_channel_desired.map(c_d => c_d.name);
let desc = ''; let desc = '';
if (all_channel_desired_name.filter(cdn => cdn == 'général').length == 0) { const general = 'général';
if (all_channel_desired_name.filter(cdn => cdn == general).length == 0) {
interaction.guild?.channels.create({ interaction.guild?.channels.create({
name: 'général', name: general,
type: 0, type: 0,
parent:cat_to_prep_id[0], parent: cat_to_prep_id[0],
}); });
desc = 'général créé \n'; desc = general + loc.get('c_prep5') + '\n';
} }
const info = 'informations';
if (all_channel_desired_name.filter(cdn => cdn == 'informations').length == 0) { if (all_channel_desired_name.filter(cdn => cdn == info).length == 0) {
interaction.guild?.channels.create({ interaction.guild?.channels.create({
name: 'informations', name: info,
type: 0, type: 0,
parent:cat_to_prep_id[0], parent: cat_to_prep_id[0],
}); });
desc += 'informations créé \n'; desc += info + loc.get('c_prep5') + '\n';
} }
if (desc == '') { if (desc == '') {
desc = 'Pas besoin de préparation'; desc = loc.get('c_prep6');
} }
return interaction.reply({ embeds: [ return interaction.reply({
new EmbedBuilder() embeds: [
.setColor('Blurple') new EmbedBuilder()
.setTitle(loc.get('c_prep4') + cat_to_prep_name) .setColor('Blurple')
.setDescription( .setTitle(loc.get('c_prep4') + cat_to_prep_name)
// Loads the description .setDescription(
// according to the user's locals // Loads the description
desc, // according to the user's locals
), desc,
] }); ),
],
});
}); });
}, },
}; };

View file

@ -24,6 +24,7 @@
"c_archive4": "Listes des Salons archivés de la catégorie `", "c_archive4": "Listes des Salons archivés de la catégorie `",
"c_archive5": "` vers `", "c_archive5": "` vers `",
"c_archive6": "Nettoyage", "c_archive6": "Nettoyage",
"c_archive7": "Catégorie déjà nettoyée",
"c_prep_name": "Préparation", "c_prep_name": "Préparation",
"c_prep_desc": "Préparation des salons généraux pour la nouvelle année", "c_prep_desc": "Préparation des salons généraux pour la nouvelle année",
@ -33,6 +34,8 @@
"c_prep2": "`L1`, `L2`, `L3`, `M1`, `M2`", "c_prep2": "`L1`, `L2`, `L3`, `M1`, `M2`",
"c_prep3": "Impossible de trouver/nettoyer le salon :", "c_prep3": "Impossible de trouver/nettoyer le salon :",
"c_prep4": "Listes des Salons préparés `", "c_prep4": "Listes des Salons préparés `",
"c_prep5": "créé",
"c_prep6": "Pas besoin de préparation",
"u_time_at": "à" "u_time_at": "à"