Development (#11)

We need this NOW.

---------

Co-authored-by: PineaFan <ash@pinea.dev>
Co-authored-by: pineafan <pineapplefanyt@gmail.com>
Co-authored-by: PineappleFan <PineaFan@users.noreply.github.com>
Co-authored-by: Skyler <skyler3665@gmail.com>
diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 9d9e653..eea33f5 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -5,16 +5,18 @@
     ActionRowBuilder,
     ButtonBuilder,
     SelectMenuBuilder,
-    ButtonStyle
+    ButtonStyle,
+    StringSelectMenuBuilder,
+    APIMessageComponentEmoji
 } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import { SlashCommandSubcommandBuilder } from "discord.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 import addPlural from "../utils/plurals.js";
 import client from "../utils/client.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
-    builder // TODO: DON'T RELEASE THIS
+    builder
         .setName("all")
         .setDescription("Gives or removes a role from everyone");
 
@@ -171,8 +173,8 @@
     const all = true;
     while (true) {
         let count = 0;
-        const affected = [];
-        const members = interaction.guild.members.cache;
+        const affected: GuildMember[] = [];
+        const members = interaction.guild!.members.cache;
         if (all) {
             members.forEach((member) => {
                 let applies = true;
@@ -224,8 +226,8 @@
                     .setStatus("Success")
             ],
             components: [
-                new ActionRowBuilder().addComponents([
-                    new SelectMenuBuilder()
+                new ActionRowBuilder<StringSelectMenuBuilder>().addComponents([
+                    new StringSelectMenuBuilder()
                         .setOptions(
                             filters.map((f, index) => ({
                                 label: (f.inverted ? "(Not) " : "") + f.name,
@@ -237,18 +239,18 @@
                         .setCustomId("select")
                         .setPlaceholder("Remove a filter")
                 ]),
-                new ActionRowBuilder().addComponents([
+                new ActionRowBuilder<ButtonBuilder>().addComponents([
                     new ButtonBuilder()
                         .setLabel("Apply")
                         .setStyle(ButtonStyle.Primary)
                         .setCustomId("apply")
-                        .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id")))
+                        .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id"))! as APIMessageComponentEmoji)
                         .setDisabled(affected.length === 0),
                     new ButtonBuilder()
                         .setLabel("Add filter")
                         .setStyle(ButtonStyle.Primary)
                         .setCustomId("add")
-                        .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
+                        .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id"))! as APIMessageComponentEmoji)
                         .setDisabled(filters.length >= 25)
                 ])
             ]
@@ -260,12 +262,12 @@
 
 const check = async (interaction: CommandInteraction) => {
     const member = interaction.member as GuildMember;
-    const me = interaction.guild.me!;
-    if (!me.permissions.has("MANAGE_ROLES")) throw new Error("I do not have the *Manage Roles* permission");
+    const me = interaction.guild!.members.me!;
+    if (!me.permissions.has("ManageRoles")) return "I do not have the *Manage Roles* permission";
     // Allow the owner to role anyone
-    if (member.id === interaction.guild.ownerId) return true;
+    if (member.id === interaction.guild!.ownerId) return true;
     // Check if the user has manage_roles permission
-    if (!member.permissions.has("MANAGE_ROLES")) throw new Error("You do not have the *Manage Roles* permission");
+    if (!member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
     // Allow role
     return true;
 };
diff --git a/src/Unfinished/categorisationTest.ts b/src/Unfinished/categorizationTest.ts
similarity index 72%
rename from src/Unfinished/categorisationTest.ts
rename to src/Unfinished/categorizationTest.ts
index dc38dfe..ff2d66b 100644
--- a/src/Unfinished/categorisationTest.ts
+++ b/src/Unfinished/categorizationTest.ts
@@ -1,28 +1,30 @@
 import { LoadingEmbed } from "../utils/defaults.js";
-import { CommandInteraction, GuildChannel, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, ButtonStyle } from "discord.js";
-import { SlashCommandBuilder } from "@discordjs/builders";
+import { CommandInteraction, GuildChannel, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, StringSelectMenuBuilder, APIMessageComponentEmoji } from "discord.js";
+import { SlashCommandBuilder } from "discord.js";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import client from "../utils/client.js";
 import addPlural from "../utils/plurals.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 
-const command = new SlashCommandBuilder().setName("categorise").setDescription("Categorises your servers channels");
+const command = new SlashCommandBuilder().setName("categorize").setDescription("Categorizes your servers channels");
 
 const callback = async (interaction: CommandInteraction): Promise<unknown> => {
-    const channels = interaction.guild.channels.cache.filter((c) => c.type !== "GUILD_CATEGORY");
-    const categorised = {};
+    const channels = interaction.guild!.channels.cache.filter((c) => c.type !== ChannelType.GuildCategory);
+    const categorized = {};
     await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
     const predicted = {};
     const types = {
-        general: ["general", "muted", "main", "topic", "discuss"],
+        important: ["rule", "announcement", "alert", "info"],
+        general: ["general", "main", "topic", "discuss"],
         commands: ["bot", "command", "music"],
-        images: ["pic", "selfies", "image"],
-        nsfw: ["porn", "nsfw", "sex"],
-        links: ["links"],
-        advertising: ["ads", "advert", "server", "partner"],
-        staff: ["staff", "mod", "admin"],
-        spam: ["spam"],
-        other: ["random"]
+        images: ["pic", "selfies", "image", "gallery", "meme", "media"],
+        nsfw: ["porn", "nsfw", "sex", "lewd", "fetish"],
+        links: ["link"],
+        advertising: ["ads", "advert", "partner", "bump"],
+        staff: ["staff", "mod", "admin", "helper", "train"],
+        spam: ["spam", "count"],
+        logs: ["log"],
+        other: ["random", "starboard"],
     };
     for (const c of channels.values()) {
         for (const type in types) {
@@ -38,14 +40,14 @@
     for (const c of channels) {
         // convert channel to a channel if its a string
         let channel: string | GuildChannel;
-        if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel as string).id;
+        if (typeof c === "string") channel = interaction.guild!.channels.cache.get(c as string)!.id;
         else channel = (c[0] as unknown as GuildChannel).id;
         console.log(channel);
         if (!predicted[channel]) predicted[channel] = [];
         m = await interaction.editReply({
             embeds: [
                 new EmojiEmbed()
-                    .setTitle("Categorise")
+                    .setTitle("Categorize")
                     .setDescription(
                         `Select all types that apply to <#${channel}>.\n\n` +
                             `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`
@@ -54,8 +56,8 @@
                     .setStatus("Success")
             ],
             components: [
-                new ActionRowBuilder().addComponents([
-                    new SelectMenuBuilder()
+                new ActionRowBuilder<StringSelectMenuBuilder>().addComponents([
+                    new StringSelectMenuBuilder()
                         .setCustomId("selected")
                         .setMaxValues(Object.keys(types).length)
                         .setMinValues(1)
@@ -67,18 +69,18 @@
                             }))
                         )
                 ]),
-                new ActionRowBuilder().addComponents([
+                new ActionRowBuilder<ButtonBuilder>().addComponents([
                     new ButtonBuilder()
                         .setLabel("Accept Suggestion")
                         .setCustomId("accept")
                         .setStyle(ButtonStyle.Success)
                         .setDisabled(predicted[channel].length === 0)
-                        .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.TICK", "id"))),
+                        .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.TICK", "id")) as APIMessageComponentEmoji),
                     new ButtonBuilder()
                         .setLabel('Use "Other"')
                         .setCustomId("reject")
                         .setStyle(ButtonStyle.Secondary)
-                        .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")))
+                        .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")) as APIMessageComponentEmoji)
                 ])
             ]
         });
@@ -86,13 +88,13 @@
         try {
             i = await m.awaitMessageComponent({
                 time: 300000,
-                filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id }
+                filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id}
             });
         } catch (e) {
             return await interaction.editReply({
                 embeds: [
                     new EmojiEmbed()
-                        .setTitle("Categorise")
+                        .setTitle("Categorize")
                         .setEmoji("CHANNEL.CATEGORY.DELETE")
                         .setStatus("Danger")
                         .setDescription(
@@ -105,7 +107,7 @@
                 ]
             });
         }
-        i.deferUpdate();
+        await i.deferUpdate();
         let selected;
         if (i.customId === "select") {
             selected = i.values;
@@ -116,9 +118,9 @@
         if (i.customId === "reject") {
             selected = ["other"];
         }
-        categorised[channel] = selected;
+        categorized[channel] = selected;
     }
-    console.log(categorised);
+    console.log(categorized);
 };
 
 const check = () => {