Bug fixes and ~~performance~~ typing improvements
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index f0b2047..577192f 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -15,19 +15,13 @@
builder
.setName("viewas")
.setDescription("View the server as a specific member")
- .addUserOption((option) =>
- option
- .setName("member")
- .setDescription("The member to view as")
- .setRequired(true)
- );
+ .addUserOption((option) => option.setName("member").setDescription("The member to view as").setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<void> => {
let channels = [];
let m;
interaction.guild.channels.cache.forEach((channel) => {
- if (!channel.parent && channel.type !== "GUILD_CATEGORY")
- channels.push(channel);
+ if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel);
});
channels = [channels];
channels = channels.concat(
@@ -38,11 +32,7 @@
const autoSortBelow = ["GUILD_VOICE", "GUILD_STAGE_VOICE"];
channels = channels.map((c) =>
c.sort((a, b) => {
- if (
- autoSortBelow.includes(a.type) &&
- autoSortBelow.includes(b.type)
- )
- return a.position - b.position;
+ if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.position - b.position;
if (autoSortBelow.includes(a.type)) return 1;
if (autoSortBelow.includes(b.type)) return -1;
return a.position - b.position;
@@ -54,9 +44,7 @@
if (!b[0].parent) return 1;
return a[0].parent.position - b[0].parent.position;
});
- const member = interaction.options.getMember(
- "member"
- ) as Discord.GuildMember;
+ const member = interaction.options.getMember("member") as Discord.GuildMember;
m = await interaction.reply({
embeds: [
new EmojiEmbed()
@@ -76,48 +64,26 @@
.setTitle("Viewing as " + member.displayName)
.setStatus("Success")
.setDescription(
- `**${
- channels[page][0].parent
- ? channels[page][0].parent.name
- : "Uncategorised"
- }**` +
+ `**${channels[page][0].parent ? channels[page][0].parent.name : "Uncategorised"}**` +
"\n" +
channels[page]
.map((c) => {
let channelType = c.type;
- if (
- interaction.guild.rulesChannelId ===
- c.id
- )
- channelType = "RULES";
- else if ("nsfw" in c && c.nsfw)
- channelType += "_NSFW";
- return c
- .permissionsFor(member)
- .has("VIEW_CHANNEL")
- ? `${getEmojiByName(
- "ICONS.CHANNEL." + channelType
- )} ${c.name}\n` +
+ if (interaction.guild.rulesChannelId === c.id) channelType = "RULES";
+ else if ("nsfw" in c && c.nsfw) channelType += "_NSFW";
+ return c.permissionsFor(member).has("VIEW_CHANNEL")
+ ? `${getEmojiByName("ICONS.CHANNEL." + channelType)} ${c.name}\n` +
(() => {
- if (
- "threads" in c &&
- c.threads.cache.size > 0
- ) {
+ if ("threads" in c && c.threads.cache.size > 0) {
return (
c.threads.cache
.map(
(t) =>
` ${
- getEmojiByName(
- "ICONS.CHANNEL.THREAD_PIPE"
- ) +
+ getEmojiByName("ICONS.CHANNEL.THREAD_PIPE") +
" " +
- getEmojiByName(
- "ICONS.CHANNEL.THREAD_CHANNEL"
- )
- } ${
- t.name
- }`
+ getEmojiByName("ICONS.CHANNEL.THREAD_CHANNEL")
+ } ${t.name}`
)
.join("\n") + "\n"
);
@@ -136,9 +102,7 @@
new MessageSelectMenu()
.setOptions(
channels.map((c, index) => ({
- label: c[0].parent
- ? c[0].parent.name
- : "Uncategorised",
+ label: c[0].parent ? c[0].parent.name : "Uncategorised",
value: index.toString(),
default: page === index
}))
@@ -195,8 +159,7 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
- if (!member.permissions.has("MANAGE_ROLES"))
- throw "You do not have the *Manage Roles* permission";
+ if (!member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
return true;
};