Reformat using prettier
diff --git a/src/commands/settings/tracks.ts b/src/commands/settings/tracks.ts
index 39efede..20972f4 100644
--- a/src/commands/settings/tracks.ts
+++ b/src/commands/settings/tracks.ts
@@ -1,4 +1,26 @@
-import { ActionRowBuilder, APIMessageComponentEmoji, ButtonBuilder, ButtonInteraction, ButtonStyle, Collection, CommandInteraction, GuildMember, Message, ModalBuilder, ModalSubmitInteraction, PermissionsBitField, Role, RoleSelectMenuBuilder, RoleSelectMenuInteraction, SlashCommandSubcommandBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction, StringSelectMenuOptionBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import {
+ ActionRowBuilder,
+ APIMessageComponentEmoji,
+ ButtonBuilder,
+ ButtonInteraction,
+ ButtonStyle,
+ Collection,
+ CommandInteraction,
+ GuildMember,
+ Message,
+ ModalBuilder,
+ ModalSubmitInteraction,
+ PermissionsBitField,
+ Role,
+ RoleSelectMenuBuilder,
+ RoleSelectMenuInteraction,
+ SlashCommandSubcommandBuilder,
+ StringSelectMenuBuilder,
+ StringSelectMenuInteraction,
+ StringSelectMenuOptionBuilder,
+ TextInputBuilder,
+ TextInputStyle
+} from "discord.js";
import client from "../../utils/client.js";
import createPageIndicator, { createVerticalTrack } from "../../utils/createPageIndicator.js";
import { LoadingEmbed } from "../../utils/defaults.js";
@@ -7,12 +29,10 @@
import ellipsis from "../../utils/ellipsis.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
-const { renderRole } = client.logger
+const { renderRole } = client.logger;
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("tracks")
- .setDescription("Manage the tracks for the server")
+ builder.setName("tracks").setDescription("Manage the tracks for the server");
interface ObjectSchema {
name: string;
@@ -22,35 +42,36 @@
manageableBy: string[];
}
-
-const editName = async (i: ButtonInteraction, interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, current?: string) => {
-
+const editName = async (
+ i: ButtonInteraction,
+ interaction: StringSelectMenuInteraction | ButtonInteraction,
+ m: Message,
+ current?: string
+) => {
let name = current ?? "";
const modal = new ModalBuilder()
.setTitle("Edit Name and Description")
.setCustomId("editNameDescription")
.addComponents(
- new ActionRowBuilder<TextInputBuilder>()
- .addComponents(
- new TextInputBuilder()
- .setLabel("Name")
- .setCustomId("name")
- .setPlaceholder("The name of the track (e.g. Moderators)")
- .setStyle(TextInputStyle.Short)
- .setValue(name)
- .setRequired(true)
- )
- )
- const button = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- )
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setLabel("Name")
+ .setCustomId("name")
+ .setPlaceholder("The name of the track (e.g. Moderators)")
+ .setStyle(TextInputStyle.Short)
+ .setValue(name)
+ .setRequired(true)
+ )
+ );
+ const button = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
- await i.showModal(modal)
+ await i.showModal(modal);
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -63,41 +84,42 @@
let out: ModalSubmitInteraction | null;
try {
- out = await modalInteractionCollector(m, interaction.user) as ModalSubmitInteraction | null;
+ out = (await modalInteractionCollector(m, interaction.user)) as ModalSubmitInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return name;
+ if (!out) return name;
if (out.isButton()) return name;
name = out.fields.fields.find((f) => f.customId === "name")?.value ?? name;
- return name
+ return name;
+};
-}
-
-const reorderTracks = async (interaction: ButtonInteraction, m: Message, roles: Collection<string, Role>, currentObj: string[]) => {
- const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("reorder")
- .setPlaceholder("Select all roles in the order you want users to gain them (Lowest to highest rank).")
- .setMinValues(currentObj.length)
- .setMaxValues(currentObj.length)
- .addOptions(
- currentObj.map((o, i) => new StringSelectMenuOptionBuilder()
- .setLabel(roles.get(o)!.name)
- .setValue(i.toString())
- )
+const reorderTracks = async (
+ interaction: ButtonInteraction,
+ m: Message,
+ roles: Collection<string, Role>,
+ currentObj: string[]
+) => {
+ const reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("reorder")
+ .setPlaceholder("Select all roles in the order you want users to gain them (Lowest to highest rank).")
+ .setMinValues(currentObj.length)
+ .setMaxValues(currentObj.length)
+ .addOptions(
+ currentObj.map((o, i) =>
+ new StringSelectMenuOptionBuilder().setLabel(roles.get(o)!.name).setValue(i.toString())
)
- );
- const buttonRow = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- )
+ )
+ );
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ );
await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -109,134 +131,154 @@
});
let out: StringSelectMenuInteraction | ButtonInteraction | null;
try {
- out = await m.awaitMessageComponent({
+ out = (await m.awaitMessageComponent({
filter: (i) => i.channel!.id === interaction.channel!.id,
time: 300000
- }) as StringSelectMenuInteraction | ButtonInteraction | null;
+ })) as StringSelectMenuInteraction | ButtonInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return;
+ if (!out) return;
out.deferUpdate();
if (out.isButton()) return;
const values = out.values;
const newOrder: string[] = currentObj.map((_, i) => {
- const index = values.findIndex(v => v === i.toString());
+ const index = values.findIndex((v) => v === i.toString());
return currentObj[index];
}) as string[];
return newOrder;
-}
+};
-const editTrack = async (interaction: ButtonInteraction | StringSelectMenuInteraction, message: Message, roles: Collection<string, Role>, current?: ObjectSchema) => {
+const editTrack = async (
+ interaction: ButtonInteraction | StringSelectMenuInteraction,
+ message: Message,
+ roles: Collection<string, Role>,
+ current?: ObjectSchema
+) => {
const isAdmin = (interaction.member!.permissions as PermissionsBitField).has("Administrator");
- if(!current) {
+ if (!current) {
current = {
name: "",
retainPrevious: false,
nullable: false,
track: [],
manageableBy: []
- }
+ };
}
- const roleSelect = new ActionRowBuilder<RoleSelectMenuBuilder>()
- .addComponents(
- new RoleSelectMenuBuilder()
- .setCustomId("addRole")
- .setPlaceholder("Select a role to add")
- .setDisabled(!isAdmin)
- );
+ const roleSelect = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(
+ new RoleSelectMenuBuilder().setCustomId("addRole").setPlaceholder("Select a role to add").setDisabled(!isAdmin)
+ );
let closed = false;
do {
- const editableRoles: string[] = current.track.map((r) => {
- if(!(roles.get(r)!.position >= (interaction.member as GuildMember).roles.highest.position) || interaction.user.id === interaction.guild?.ownerId) return roles.get(r)!.name;
- }).filter(v => v !== undefined) as string[];
- const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>()
- .addComponents(
- new StringSelectMenuBuilder()
- .setCustomId("removeRole")
- .setPlaceholder("Select a role to remove")
- .setDisabled(!isAdmin)
- .addOptions(
- editableRoles.map((r, i) => {
- return new StringSelectMenuOptionBuilder()
- .setLabel(r)
- .setValue(i.toString())}
- )
- )
- );
- const buttons = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setLabel("Back")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("edit")
- .setLabel("Edit Name")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("reorder")
- .setLabel("Reorder")
- .setDisabled(!isAdmin)
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("ICONS.REORDER", "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("retainPrevious")
- .setLabel("Retain Previous")
- .setStyle(current.retainPrevious ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji),
- new ButtonBuilder()
- .setCustomId("nullable")
- .setLabel(`Role ${current.nullable ? "Not " : ""}Required`)
- .setStyle(current.nullable ? ButtonStyle.Success : ButtonStyle.Danger)
- .setEmoji(getEmojiByName("CONTROL." + (current.nullable ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji)
+ const editableRoles: string[] = current.track
+ .map((r) => {
+ if (
+ !(roles.get(r)!.position >= (interaction.member as GuildMember).roles.highest.position) ||
+ interaction.user.id === interaction.guild?.ownerId
+ )
+ return roles.get(r)!.name;
+ })
+ .filter((v) => v !== undefined) as string[];
+ const selectMenu = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("removeRole")
+ .setPlaceholder("Select a role to remove")
+ .setDisabled(!isAdmin)
+ .addOptions(
+ editableRoles.map((r, i) => {
+ return new StringSelectMenuOptionBuilder().setLabel(r).setValue(i.toString());
+ })
+ )
+ );
+ const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setLabel("Back")
+ .setStyle(ButtonStyle.Secondary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("edit")
+ .setLabel("Edit Name")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.EDIT", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("reorder")
+ .setLabel("Reorder")
+ .setDisabled(!isAdmin)
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("ICONS.REORDER", "id") as APIMessageComponentEmoji),
+ new ButtonBuilder()
+ .setCustomId("retainPrevious")
+ .setLabel("Retain Previous")
+ .setStyle(current.retainPrevious ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName(
+ "CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"),
+ "id"
+ ) as APIMessageComponentEmoji
+ ),
+ new ButtonBuilder()
+ .setCustomId("nullable")
+ .setLabel(`Role ${current.nullable ? "Not " : ""}Required`)
+ .setStyle(current.nullable ? ButtonStyle.Success : ButtonStyle.Danger)
+ .setEmoji(
+ getEmojiByName("CONTROL." + (current.nullable ? "TICK" : "CROSS"), "id") as APIMessageComponentEmoji
+ )
);
const allowed: boolean[] = [];
for (const role of current.track) {
const disabled: boolean =
roles.get(role)!.position >= (interaction.member as GuildMember).roles.highest.position;
- allowed.push(disabled)
+ allowed.push(disabled);
}
- const mapped = current.track.map(role => roles.find(aRole => aRole.id === role)!);
+ const mapped = current.track.map((role) => roles.find((aRole) => aRole.id === role)!);
const embed = new EmojiEmbed()
.setTitle("Tracks")
.setDescription(
`**Currently Editing:** ${current.name}\n\n` +
- `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${current.nullable ? "don't " : ""}need a role in this track\n` +
- `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${current.retainPrevious ? "" : "don't "}keep all roles below their current highest\n\n` +
- createVerticalTrack(
- mapped.map(role => renderRole(role)), new Array(current.track.length).fill(false), allowed)
+ `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${
+ current.nullable ? "don't " : ""
+ }need a role in this track\n` +
+ `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${
+ current.retainPrevious ? "" : "don't "
+ }keep all roles below their current highest\n\n` +
+ createVerticalTrack(
+ mapped.map((role) => renderRole(role)),
+ new Array(current.track.length).fill(false),
+ allowed
+ )
)
- .setStatus("Success")
+ .setStatus("Success");
- const comps: ActionRowBuilder<RoleSelectMenuBuilder | ButtonBuilder | StringSelectMenuBuilder>[] = [roleSelect, buttons];
- if(current.track.length >= 1) comps.splice(1, 0, selectMenu);
+ const comps: ActionRowBuilder<RoleSelectMenuBuilder | ButtonBuilder | StringSelectMenuBuilder>[] = [
+ roleSelect,
+ buttons
+ ];
+ if (current.track.length >= 1) comps.splice(1, 0, selectMenu);
- interaction.editReply({embeds: [embed], components: comps});
+ interaction.editReply({ embeds: [embed], components: comps });
let out: ButtonInteraction | RoleSelectMenuInteraction | StringSelectMenuInteraction | null;
try {
- out = await message.awaitMessageComponent({
+ out = (await message.awaitMessageComponent({
filter: (i) => i.channel!.id === interaction.channel!.id,
time: 300000
- }) as ButtonInteraction | RoleSelectMenuInteraction | StringSelectMenuInteraction | null;
+ })) as ButtonInteraction | RoleSelectMenuInteraction | StringSelectMenuInteraction | null;
} catch (e) {
console.error(e);
out = null;
}
- if(!out) return;
+ if (!out) return;
if (out.isButton()) {
- switch(out.customId) {
+ switch (out.customId) {
case "back": {
out.deferUpdate();
closed = true;
@@ -264,34 +306,34 @@
}
} else if (out.isStringSelectMenu()) {
out.deferUpdate();
- switch(out.customId) {
+ switch (out.customId) {
case "removeRole": {
- const index = current.track.findIndex(v => v === editableRoles[parseInt((out! as StringSelectMenuInteraction).values![0]!)]);
+ const index = current.track.findIndex(
+ (v) => v === editableRoles[parseInt((out! as StringSelectMenuInteraction).values![0]!)]
+ );
current.track.splice(index, 1);
break;
}
}
} else {
- switch(out.customId) {
+ switch (out.customId) {
case "addRole": {
const role = out.values![0]!;
- if(!current.track.includes(role)) {
+ if (!current.track.includes(role)) {
current.track.push(role);
} else {
- out.reply({content: "That role is already on this track", ephemeral: true})
+ out.reply({ content: "That role is already on this track", ephemeral: true });
}
break;
}
}
}
-
- } while(!closed);
+ } while (!closed);
return current;
-}
+};
const callback = async (interaction: CommandInteraction) => {
-
- const m = await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true})
+ const m = await interaction.reply({ embeds: LoadingEmbed, fetchReply: true, ephemeral: true });
const config = await client.database.guilds.read(interaction.guild!.id);
const tracks: ObjectSchema[] = config.tracks;
const roles = await interaction.guild!.roles.fetch();
@@ -301,16 +343,11 @@
let modified = false;
do {
- const embed = new EmojiEmbed()
- .setTitle("Track Settings")
- .setEmoji("TRACKS.ICON")
- .setStatus("Success");
+ const embed = new EmojiEmbed().setTitle("Track Settings").setEmoji("TRACKS.ICON").setStatus("Success");
const noTracks = config.tracks.length === 0;
let current: ObjectSchema;
- const pageSelect = new StringSelectMenuBuilder()
- .setCustomId("page")
- .setPlaceholder("Select a track to manage");
+ const pageSelect = new StringSelectMenuBuilder().setCustomId("page").setPlaceholder("Select a track to manage");
const actionSelect = new StringSelectMenuBuilder()
.setCustomId("action")
.setPlaceholder("Perform an action")
@@ -325,51 +362,56 @@
.setDescription("Delete this track")
.setValue("delete")
.setEmoji(getEmojiByName("TICKETS.ISSUE", "id") as APIMessageComponentEmoji)
- );
- const buttonRow = new ActionRowBuilder<ButtonBuilder>()
- .addComponents(
- new ButtonBuilder()
- .setCustomId("back")
- .setStyle(ButtonStyle.Primary)
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
- .setDisabled(page === 0),
- new ButtonBuilder()
- .setCustomId("next")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Primary)
- .setDisabled(page === tracks.length - 1),
- new ButtonBuilder()
- .setCustomId("add")
- .setLabel("New Track")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Secondary)
- .setDisabled(Object.keys(tracks).length >= 24),
- new ButtonBuilder()
- .setCustomId("save")
- .setLabel("Save")
- .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
- .setStyle(ButtonStyle.Success)
- .setDisabled(!modified),
);
- if(noTracks) {
- embed.setDescription("No tracks have been set up yet. Use the button below to add one.\n\n" +
- createPageIndicator(1, 1, undefined, true)
+ const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder()
+ .setCustomId("back")
+ .setStyle(ButtonStyle.Primary)
+ .setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji)
+ .setDisabled(page === 0),
+ new ButtonBuilder()
+ .setCustomId("next")
+ .setEmoji(getEmojiByName("CONTROL.RIGHT", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Primary)
+ .setDisabled(page === tracks.length - 1),
+ new ButtonBuilder()
+ .setCustomId("add")
+ .setLabel("New Track")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Secondary)
+ .setDisabled(Object.keys(tracks).length >= 24),
+ new ButtonBuilder()
+ .setCustomId("save")
+ .setLabel("Save")
+ .setEmoji(getEmojiByName("ICONS.SAVE", "id") as APIMessageComponentEmoji)
+ .setStyle(ButtonStyle.Success)
+ .setDisabled(!modified)
+ );
+ if (noTracks) {
+ embed.setDescription(
+ "No tracks have been set up yet. Use the button below to add one.\n\n" +
+ createPageIndicator(1, 1, undefined, true)
);
pageSelect.setDisabled(true);
actionSelect.setDisabled(true);
- pageSelect.addOptions(new StringSelectMenuOptionBuilder()
- .setLabel("No tracks")
- .setValue("none")
- );
+ pageSelect.addOptions(new StringSelectMenuOptionBuilder().setLabel("No tracks").setValue("none"));
} else {
page = Math.min(page, Object.keys(tracks).length - 1);
current = tracks[page]!;
- const mapped = current.track.map(role => roles.find(aRole => aRole.id === role)!);
- embed.setDescription(`**Currently Editing:** ${current.name}\n\n` +
- `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${current.nullable ? "don't " : ""}need a role in this track\n` +
- `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${current.retainPrevious ? "" : "don't "}keep all roles below their current highest\n\n` +
- createVerticalTrack(mapped.map(role => renderRole(role)), new Array(current.track.length).fill(false)) +
- `\n${createPageIndicator(config.tracks.length, page)}`
+ const mapped = current.track.map((role) => roles.find((aRole) => aRole.id === role)!);
+ embed.setDescription(
+ `**Currently Editing:** ${current.name}\n\n` +
+ `${getEmojiByName("CONTROL." + (current.nullable ? "CROSS" : "TICK"))} Members ${
+ current.nullable ? "don't " : ""
+ }need a role in this track\n` +
+ `${getEmojiByName("CONTROL." + (current.retainPrevious ? "TICK" : "CROSS"))} Members ${
+ current.retainPrevious ? "" : "don't "
+ }keep all roles below their current highest\n\n` +
+ createVerticalTrack(
+ mapped.map((role) => renderRole(role)),
+ new Array(current.track.length).fill(false)
+ ) +
+ `\n${createPageIndicator(config.tracks.length, page)}`
);
pageSelect.addOptions(
@@ -380,13 +422,23 @@
.setValue(index.toString());
})
);
-
}
- await interaction.editReply({embeds: [embed], components: [new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect), new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect), buttonRow]});
+ await interaction.editReply({
+ embeds: [embed],
+ components: [
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(actionSelect),
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(pageSelect),
+ buttonRow
+ ]
+ });
let i: StringSelectMenuInteraction | ButtonInteraction;
try {
- i = await m.awaitMessageComponent({ time: 300000, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId}) as ButtonInteraction | StringSelectMenuInteraction;
+ i = (await m.awaitMessageComponent({
+ time: 300000,
+ filter: (i) =>
+ i.user.id === interaction.user.id && i.message.id === m.id && i.channelId === interaction.channelId
+ })) as ButtonInteraction | StringSelectMenuInteraction;
} catch (e) {
closed = true;
continue;
@@ -404,14 +456,14 @@
break;
}
case "add": {
- const newPage = await editTrack(i, m, roles)
- if(!newPage) break;
+ const newPage = await editTrack(i, m, roles);
+ if (!newPage) break;
tracks.push();
page = tracks.length - 1;
break;
}
case "save": {
- client.database.guilds.write(interaction.guild!.id, {tracks: tracks});
+ client.database.guilds.write(interaction.guild!.id, { tracks: tracks });
modified = false;
await client.memory.forceUpdate(interaction.guild!.id);
break;
@@ -420,16 +472,16 @@
} else if (i.isStringSelectMenu()) {
switch (i.customId) {
case "action": {
- switch(i.values[0]) {
+ switch (i.values[0]) {
case "edit": {
const edited = await editTrack(i, m, roles, current!);
- if(!edited) break;
+ if (!edited) break;
tracks[page] = edited;
modified = true;
break;
}
case "delete": {
- if(page === 0 && tracks.keys.length - 1 > 0) page++;
+ if (page === 0 && tracks.keys.length - 1 > 0) page++;
else page--;
tracks.splice(page, 1);
break;
@@ -443,10 +495,9 @@
}
}
}
-
} while (!closed);
- await interaction.deleteReply()
-}
+ await interaction.deleteReply();
+};
const check = (interaction: CommandInteraction, _partial: boolean = false) => {
const member = interaction.member as GuildMember;