diff --git a/src/actions/roleMenu.ts b/src/actions/roleMenu.ts
index 732c94d..16689b7 100644
--- a/src/actions/roleMenu.ts
+++ b/src/actions/roleMenu.ts
@@ -30,6 +30,36 @@
     interaction: CommandInteraction | ButtonInteraction | ContextMenuCommandInteraction;
 }
 
+interface ObjectSchema {
+    name: string;
+    description: string;
+    min: number;
+    max: number;
+    options: {
+        name: string;
+        description: string | null;
+        role: string;
+    }[];
+}
+
+export const configToDropdown = (placeholder: string, currentPageData: ObjectSchema, selectedRoles?: string[]): ActionRowBuilder<StringSelectMenuBuilder> => {
+    return new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+        new StringSelectMenuBuilder()
+            .setCustomId("roles")
+            .setPlaceholder(placeholder)
+            .setMinValues(currentPageData.min)
+            .setMaxValues(currentPageData.max)
+            .addOptions(currentPageData.options.map((option: {name: string; description: string | null; role: string;}) => {
+                const builder = new StringSelectMenuOptionBuilder()
+                    .setLabel(option.name)
+                    .setValue(option.role)
+                    .setDefault(selectedRoles ? selectedRoles.includes(option.role) : false);
+                if (option.description) builder.setDescription(option.description);
+                return builder;
+            }))
+    )
+}
+
 export async function callback(interaction: CommandInteraction | ButtonInteraction) {
     if (!interaction.member) return;
     if (!interaction.guild) return;
@@ -56,7 +86,7 @@
             ],
             ephemeral: true
         });
-    const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
+    const m = await interaction.reply({ embeds: LoadingEmbed, ephemeral: true, fetchReply: true });
     if (config.roleMenu.allowWebUI) {  // TODO: Make rolemenu web ui
         const loginMethods: {webUI: boolean} = {
             webUI: false
@@ -124,9 +154,10 @@
             try {
                 component = await m.awaitMessageComponent({
                     time: 300000,
-                    filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id  && i.message.id === m.id}
+                    filter: (i) => { return i.user.id === interaction.user.id && i.channelId === interaction.channelId  && i.message.id === m.id}
                 });
             } catch (e) {
+                console.log(e);
                 return;
             }
             component.deferUpdate();
@@ -175,21 +206,7 @@
                     .setCustomId("done")
                     .setDisabled(!complete)
             ),
-            new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
-                new StringSelectMenuBuilder()
-                    .setCustomId("roles")
-                    .setPlaceholder("Select...")
-                    .setMinValues(currentPageData.min)
-                    .setMaxValues(currentPageData.max)
-                    .addOptions(currentPageData.options.map((option) => {
-                        const builder = new StringSelectMenuOptionBuilder()
-                            .setLabel(option.name)
-                            .setValue(option.role)
-                            .setDefault(selectedRoles[page]!.includes(option.role));
-                        if (option.description) builder.setDescription(option.description);
-                        return builder;
-                    }))
-            )
+            configToDropdown("Select...", currentPageData, selectedRoles[page])
         ];
         await interaction.editReply({
             embeds: [embed],
@@ -202,6 +219,7 @@
                 filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.message.id === m.id}
             });
         } catch (e) {
+            console.log(e);
             return;
         }
         component.deferUpdate();
