worked on settings/rolemenu and help
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();