Reformat using prettier
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index ef62816..41f34b9 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../../utils/defaults.js';
+import { LoadingEmbed } from "./../../utils/defaults.js";
import Discord, {
CommandInteraction,
GuildMember,
@@ -23,20 +23,19 @@
.addUserOption((option) => option.setName("member").setDescription("The member to view as").setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<void> => {
+ const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
-
- let channels: Record<string, GuildBasedChannel[]> = {"": []};
+ let channels: Record<string, GuildBasedChannel[]> = { "": [] };
const channelCollection = await interaction.guild!.channels.fetch();
- channelCollection.forEach(channel => {
+ channelCollection.forEach((channel) => {
if (!channel) return; // if no channel
if (channel.type === Discord.ChannelType.GuildCategory) {
- if(!channels[channel!.id]) channels[channel!.id] = [];
+ if (!channels[channel!.id]) channels[channel!.id] = [];
} else if (channel.parent) {
if (!channels[channel.parent.id]) channels[channel.parent.id] = [channel];
- else (channels[channel.parent.id as string])!.push(channel);
+ else channels[channel.parent.id as string]!.push(channel);
} else {
channels[""]!.push(channel);
}
@@ -47,7 +46,11 @@
for (const category in channels) {
channels[category] = channels[category]!.sort((a: GuildBasedChannel, b: GuildBasedChannel) => {
- const disallowedTypes = [Discord.ChannelType.PublicThread, Discord.ChannelType.PrivateThread, Discord.ChannelType.AnnouncementThread];
+ const disallowedTypes = [
+ Discord.ChannelType.PublicThread,
+ Discord.ChannelType.PrivateThread,
+ Discord.ChannelType.AnnouncementThread
+ ];
if (disallowedTypes.includes(a.type) || disallowedTypes.includes(b.type)) return 0;
a = a as NonThreadGuildBasedChannel;
b = b as NonThreadGuildBasedChannel;
@@ -64,7 +67,11 @@
}
for (const category in channels) {
channels[category] = channels[category]!.filter((c) => {
- return !(c.type === Discord.ChannelType.PublicThread || c.type === Discord.ChannelType.PrivateThread || c.type === Discord.ChannelType.AnnouncementThread)
+ return !(
+ c.type === Discord.ChannelType.PublicThread ||
+ c.type === Discord.ChannelType.PrivateThread ||
+ c.type === Discord.ChannelType.AnnouncementThread
+ );
});
}
channels = Object.fromEntries(Object.entries(channels).filter(([_, v]) => v.length > 0));
@@ -81,12 +88,12 @@
if (last25.length > 0) categoryNames25.push(last25);
const channelTypeEmoji: Record<number, string> = {
- 0: "GUILD_TEXT", // Text channel
- 2: "GUILD_VOICE", // Voice channel
- 5: "GUILD_NEWS", // Announcement channel
- 13: "GUILD_STAGE_VOICE", // Stage channel
- 15: "FORUM", // Forum channel
- 99: "RULES" // Rules channel
+ 0: "GUILD_TEXT", // Text channel
+ 2: "GUILD_VOICE", // Voice channel
+ 5: "GUILD_NEWS", // Announcement channel
+ 13: "GUILD_STAGE_VOICE", // Stage channel
+ 15: "FORUM", // Forum channel
+ 99: "RULES" // Rules channel
};
const NSFWAvailable: number[] = [0, 2, 5, 13];
const rulesChannel = interaction.guild!.rulesChannel?.id;
@@ -94,12 +101,12 @@
async function nameFromChannel(channel: GuildBasedChannel): Promise<string> {
let channelType: Discord.ChannelType | 99 = channel.type;
if (channelType === Discord.ChannelType.GuildCategory) return "";
- if (channel.id === rulesChannel) channelType = 99
+ if (channel.id === rulesChannel) channelType = 99;
let threads: Discord.ThreadChannel[] = [];
if ("threads" in channel) {
threads = channel.threads.cache.toJSON().map((t) => t as Discord.ThreadChannel);
}
- const nsfw = ("nsfw" in channel ? channel.nsfw : false) && NSFWAvailable.includes(channelType)
+ const nsfw = ("nsfw" in channel ? channel.nsfw : false) && NSFWAvailable.includes(channelType);
const emojiName = channelTypeEmoji[channelType.valueOf()] + (nsfw ? "_NSFW" : "");
const emoji = getEmojiByName("ICONS.CHANNEL." + (threads.length ? "THREAD_CHANNEL" : emojiName));
let current = `${emoji} ${channel.name}`;
@@ -118,46 +125,59 @@
description += `${await nameFromChannel(channel)}\n`;
}
- const parsedCategorySelectMenu: ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>[] = categoryNames25.map(
- (categories, set) => { return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(new StringSelectMenuBuilder()
- .setCustomId("category")
- .setMinValues(1)
- .setMaxValues(1)
- .setOptions(categories.map((c, i) => {
- return new StringSelectMenuOptionBuilder()
- .setLabel(c)
- .setValue((set * 25 + i).toString())
- .setEmoji(getEmojiByName("ICONS.CHANNEL.CATEGORY", "id") as APIMessageComponentEmoji) // Again, this is valid but TS doesn't think so
- .setDefault((set * 25 + i) === page)
- }))
- )}
+ const parsedCategorySelectMenu: ActionRowBuilder<StringSelectMenuBuilder | ButtonBuilder>[] =
+ categoryNames25.map((categories, set) => {
+ return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("category")
+ .setMinValues(1)
+ .setMaxValues(1)
+ .setOptions(
+ categories.map((c, i) => {
+ return new StringSelectMenuOptionBuilder()
+ .setLabel(c)
+ .setValue((set * 25 + i).toString())
+ .setEmoji(
+ getEmojiByName("ICONS.CHANNEL.CATEGORY", "id") as APIMessageComponentEmoji
+ ) // Again, this is valid but TS doesn't think so
+ .setDefault(set * 25 + i === page);
+ })
+ )
+ );
+ });
+
+ const components: ActionRowBuilder<ButtonBuilder | StringSelectMenuBuilder>[] = parsedCategorySelectMenu;
+ components.push(
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(page === 0)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
+ new ButtonBuilder()
+ .setCustomId("right")
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(page === categoryIDs.length - 1)
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
+ )
);
- const components: ActionRowBuilder<ButtonBuilder | StringSelectMenuBuilder>[] = parsedCategorySelectMenu
- components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(page === 0)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id")),
- new ButtonBuilder()
- .setCustomId("right")
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(page === categoryIDs.length - 1)
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- ));
-
await interaction.editReply({
- embeds: [new EmojiEmbed()
- .setEmoji("MEMBER.JOIN")
- .setTitle("Viewing as " + member.displayName)
- .setStatus("Success")
- .setDescription(description + "\n" + pageIndicator(categoryIDs.length, page))
- ], components: components
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("MEMBER.JOIN")
+ .setTitle("Viewing as " + member.displayName)
+ .setStatus("Success")
+ .setDescription(description + "\n" + pageIndicator(categoryIDs.length, page))
+ ],
+ components: components
});
let i;
try {
- i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 30000});
+ i = await m.awaitMessageComponent({
+ filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id,
+ time: 30000
+ });
} catch (e) {
closed = true;
continue;