diff --git a/commands/armbands.js b/commands/armbands.js index 23947b5..a0c7d43 100644 --- a/commands/armbands.js +++ b/commands/armbands.js @@ -1,4 +1,5 @@ -const { ModalBuilder, ActionRowBuilder } = require('discord.js'); +const { SelectMenuBuilder, EmbedBuilder, ActionRowBuilder } = require('discord.js'); +const { Armbands } = require('../config/armbandsdb.js'); module.exports = { name: "armbands", @@ -19,14 +20,64 @@ module.exports = { * @param {string[]} args * @param {*} param3 */ - run: async (client, interaction, args) => { + run: async (client, interaction, args, { GuildDB }) => { + let available = new SelectMenuBuilder() + .setCustomId(`View-1-${interaction.member.user.id}`) + .setPlaceholder('Select an armband from list 1 to claim') + + let availableNext = new SelectMenuBuilder() + .setCustomId(`View-2-${interaction.member.user.id}`) + .setPlaceholder('Select an armband from list 2 to claim') + + let tracker = 0; + for (let i = 0; i < Armbands.length; i++) { + tracker++; + data = { + label: Armbands[i].name, + description: 'View this armband', + value: Armbands[i].name, + } + + if (GuildDB.usedArmbands.includes(Armbands[i].name)) data.label += ' - [ Claimed ]' + + if (tracker > 25) availableNext.addOptions(data); + else available.addOptions(data); + } + + let compList = [] + + let opt = new ActionRowBuilder().addComponents(available); + compList.push(opt) + let opt2 = undefined; + if (tracker > 25) { + opt2 = new ActionRowBuilder().addComponents(availableNext); + compList.push(opt2); + } + + return interaction.send({ components: compList, flags: (1 << 6) }); }, }, Interactions: { - ViewArmbads: { - run: async (client, interaction) => { + View: { + run: async (client, interaction, GuildDB) => { + let armbandURL; + for (let i = 0; i < Armbands.length; i++) { + if (Armbands[i].name == interaction.values[0]) { + armbandURL = Armbands[i].url; + break; + } + } + + let armbandTitle = `${interaction.values[0]}${GuildDB.usedArmbands.includes(interaction.values[0]) ? ' - [ Claimed ]' : ''}`; + + const success = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle(armbandTitle) + .setImage(armbandURL); + + return interaction.update({ embeds: [success], components: [] }); } } } diff --git a/commands/claim.js b/commands/claim.js index 7c3bde2..9fa4d89 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -118,10 +118,10 @@ module.exports = { const success = new EmbedBuilder() .setColor(client.config.Colors.Default) - .setDescription(`**Success!**\n> The faction <@&${factionID}> has now claimed *${interaction.values[0]}*`) + .setDescription(`**Success!**\n> The faction <@&${factionID}> has now claimed ***${interaction.values[0]}***`) .setImage(armbandURL); - return interaction.update({ embeds: [success], components: [], flags: 0 }); + return interaction.update({ embeds: [success], components: [] }); } }, diff --git a/commands/factions.js b/commands/factions.js new file mode 100644 index 0000000..613d397 --- /dev/null +++ b/commands/factions.js @@ -0,0 +1,27 @@ +const { ModalBuilder, ActionRowBuilder } = require('discord.js'); + +module.exports = { + name: "factions", + debug: false, + global: false, + description: "view the armband of a faction", + usage: "[cmd] [opts]", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: [], + }, + options: [], + SlashCommand: { + /** + * + * @param {require("../structures/QuarksBot")} client + * @param {import("discord.js").Message} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, interaction, args) => { + + }, + }, + Interactions: {} +}