fixed rolemenu/tracks
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 154fe71..0c174f5 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -163,19 +163,20 @@
return [name, description];
};
+const defaultRoleMenuData = {
+ name: "Role Menu Page",
+ description: "A new role menu page",
+ min: 0,
+ max: 0,
+ options: []
+};
+
const editRoleMenuPage = async (
interaction: StringSelectMenuInteraction | ButtonInteraction,
m: Message,
data?: ObjectSchema
): Promise<ObjectSchema | null> => {
- if (!data)
- data = {
- name: "Role Menu Page",
- description: "A new role menu page",
- min: 0,
- max: 0,
- options: []
- };
+ if (!data) data = _.cloneDeep(defaultRoleMenuData)
const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("back")
@@ -472,7 +473,7 @@
}
case "add": {
const newPage = await editRoleMenuPage(i, m);
- if (!newPage) break;
+ if (_.isEqual(newPage, defaultRoleMenuData)) break;
currentObject.push();
page = currentObject.length - 1;
break;
diff --git a/src/commands/settings/tracks.ts b/src/commands/settings/tracks.ts
index 3914a6c..625bcfb 100644
--- a/src/commands/settings/tracks.ts
+++ b/src/commands/settings/tracks.ts
@@ -28,6 +28,7 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
import ellipsis from "../../utils/ellipsis.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
+import _ from "lodash";
const { renderRole } = client.logger;
@@ -96,7 +97,8 @@
};
const reorderTracks = async (
- interaction: ButtonInteraction,
+ interaction: ButtonInteraction | StringSelectMenuInteraction,
+ buttonInteraction: ButtonInteraction,
m: Message,
roles: Collection<string, Role>,
currentObj: string[]
@@ -132,7 +134,7 @@
let out: StringSelectMenuInteraction | ButtonInteraction | null;
try {
out = (await m.awaitMessageComponent({
- filter: (i) => i.channel!.id === interaction.channel!.id,
+ filter: (i) => i.channel!.id === buttonInteraction.channel!.id,
time: 300000
})) as StringSelectMenuInteraction | ButtonInteraction | null;
} catch (e) {
@@ -152,6 +154,14 @@
return newOrder;
};
+const defaultTrackData = {
+ name: "",
+ retainPrevious: false,
+ nullable: true,
+ track: [],
+ manageableBy: []
+};
+
const editTrack = async (
interaction: ButtonInteraction | StringSelectMenuInteraction,
message: Message,
@@ -160,13 +170,7 @@
) => {
const isAdmin = (interaction.member!.permissions as PermissionsBitField).has("Administrator");
if (!current) {
- current = {
- name: "",
- retainPrevious: false,
- nullable: true,
- track: [],
- manageableBy: []
- };
+ current = _.cloneDeep(defaultTrackData);
}
const roleSelect = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
@@ -292,7 +296,7 @@
}
case "reorder": {
out.deferUpdate();
- current.track = (await reorderTracks(out, message, roles, current.track))!;
+ current.track = (await reorderTracks(interaction, out, message, roles, current.track))!;
break;
}
case "retainPrevious": {
@@ -466,7 +470,7 @@
}
case "add": {
const newPage = await editTrack(i, m, roles);
- if (!newPage) break;
+ if (_.isEqual(newPage, defaultTrackData)) break;
tracks.push();
page = tracks.length - 1;
break;