fix getter of archived category

This commit is contained in:
Mylloon 2023-01-17 15:46:09 +01:00
parent cb00362a82
commit ee642ae6e4
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { CategoryChannelResolvable, ChannelType, Client, CommandInteraction, EmbedBuilder, NonThreadGuildBasedChannel } from 'discord.js';
import { ChannelType, Client, CommandInteraction, EmbedBuilder, NonThreadGuildBasedChannel } from 'discord.js';
import '../../modules/string';
import { getLocale, getLocalizations } from '../../utils/locales';
import { getFilename } from '../../utils/misc';
@ -71,15 +71,17 @@ export default {
// Create/Retrieve the archive category
const catArchivedName = 'archive - ' + desiredCat;
const getCatArchived = () => channelGuild
const catArchivedMap = channelGuild
.filter(chan => chan?.type == ChannelType.GuildCategory)
.filter(chan => chan?.name == catArchivedName);
if (getCatArchived().size == 0) {
await interaction.guild?.channels
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 catArchived = getCatArchived().at(0);
const allChannelDesired = channelGuild
.filter(chan => chan?.type == 0)
@ -99,7 +101,7 @@ export default {
});
}
// Move channels to the archived category
// Move channels to the archived categoryx
allChannelDesired.forEach(elem => elem?.setParent(catArchived?.id as string));
return interaction.reply({
@ -107,11 +109,11 @@ export default {
new EmbedBuilder()
.setColor('Blurple')
.setTitle(loc.get('c_archive4')
+ '`'
+ ' `'
+ catToArchive.map(cat => cat?.name)
+ '`'
+ '` '
+ loc.get('c_archive5')
+ '`'
+ ' `'
+ catArchivedName
+ '`')
.setDescription(