view a list of armbands
This commit is contained in:
3 files changed
+84
-6
No files matched your search
+55
-4
@@ -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: [] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user