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;
 };
 
