updated settings commands
Co-authored-by: PineappleFan <PineaFan@users.noreply.github.com>
Co-authored-by: Grey, Skyler <ST137303@hillsroad.ac.uk>
diff --git a/src/commands/settings/filters/_meta.ts b/src/commands/settings/filters/_meta.ts
new file mode 100644
index 0000000..d2aff53
--- /dev/null
+++ b/src/commands/settings/filters/_meta.ts
@@ -0,0 +1,8 @@
+import { group } from "../../../utils/commandRegistration/slashCommandBuilder.js";
+
+const name = "filters";
+const description = "Settings for filters";
+
+const subcommand = await group(name, description, `settings/filters`)
+
+export { name, description, subcommand as command};
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index 1591273..8796892 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -9,7 +9,9 @@
import { configToDropdown } from "../../actions/roleMenu.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
import lodash from 'lodash';
+
const isEqual = lodash.isEqual;
+
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("rolemenu")
@@ -37,6 +39,60 @@
]
}
+const reorderRoleMenuPages = async (interaction: CommandInteraction, m: Message, currentObj: ObjectSchema[]) => {
+ let reorderRow = new ActionRowBuilder<StringSelectMenuBuilder>()
+ .addComponents(
+ new StringSelectMenuBuilder()
+ .setCustomId("reorder")
+ .setPlaceholder("Select a page to move...")
+ .setMinValues(1)
+ .addOptions(
+ currentObj.map((o, i) => new StringSelectMenuOptionBuilder()
+ .setLabel(o.name)
+ .setValue(i.toString())
+ )
+ )
+ );
+ let 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()
+ .setTitle("Role Menu")
+ .setDescription("Select pages in the order you want them to appear.")
+ .setStatus("Success")
+ ],
+ components: [reorderRow, buttonRow]
+ });
+ let out: StringSelectMenuInteraction | ButtonInteraction | null;
+ try {
+ out = await m.awaitMessageComponent({
+ filter: (i) => i.channel!.id === interaction.channel!.id,
+ time: 300000
+ }) as StringSelectMenuInteraction | ButtonInteraction | null;
+ } catch (e) {
+ console.error(e);
+ out = null;
+ }
+ if(!out) return;
+ if (out.isButton()) return;
+ if(!out.values) return;
+ const values = out.values;
+
+ const newOrder: ObjectSchema[] = currentObj.map((_, i) => {
+ const index = values.findIndex(v => v === i.toString());
+ return currentObj[index];
+ }) as ObjectSchema[];
+
+ return newOrder;
+}
+
const editNameDescription = async (i: ButtonInteraction, interaction: StringSelectMenuInteraction | ButtonInteraction, m: Message, data: {name?: string, description?: string}) => {
let {name, description} = data;
@@ -374,6 +430,9 @@
page = currentObject.length - 1;
break;
case "reorder":
+ let reordered = await reorderRoleMenuPages(interaction, m, currentObject);
+ if(!reordered) break;
+ currentObject = reordered;
break;
case "save":
client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject});
diff --git a/src/commands/settings/tracks.ts b/src/commands/settings/tracks.ts
new file mode 100644
index 0000000..0cad55c
--- /dev/null
+++ b/src/commands/settings/tracks.ts
@@ -0,0 +1,26 @@
+import type { CommandInteraction, GuildMember, SlashCommandSubcommandBuilder } from "discord.js";
+import client from "../../utils/client.js";
+
+
+const command = (builder: SlashCommandSubcommandBuilder) =>
+ builder
+ .setName("tracks")
+ .setDescription("Manage the tracks for the server")
+
+
+const callback = async (interaction: CommandInteraction) => {
+
+
+
+}
+
+const check = (interaction: CommandInteraction, _partial: boolean = false) => {
+ const member = interaction.member as GuildMember;
+ if (!member.permissions.has("ManageRoles"))
+ return "You must have the *Manage Server* permission to use this command";
+ return true;
+};
+
+export { command };
+export { callback };
+export { check };