view specific factions armband

This commit is contained in:
SowinskiBraeden committed 2022-12-15 15:36:40 -08:00
1 parent 9b276a2201
commit 6ce9e972e0
2 files changed
+54 -15

No files matched your search

+53 -14
View File
@@ -1,4 +1,5 @@
const { EmbedBuilder } = require('discord.js');
const { Armbands } = require('../config/armbandsdb.js');
module.exports = {
name: "factions",
@@ -10,7 +11,13 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
options: [],
options: [{
name: "faction_role",
description: "View a specific faction's armband by role",
value: "faction_role",
type: 8,
required: false,
}],
SlashCommand: {
/**
*
@@ -23,24 +30,56 @@ module.exports = {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id))
return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) });
let factions = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('Factions & Armbands')
// Return list of factions and their armband.
if (!args) {
let factions = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('Factions & Armbands')
let description = '';
let description = '';
if (GuildDB.usedArmbands.length == 0) {
description = '> There are no factions that have claimed armbands.';
} else {
for (const [factionID, data] of Object.entries(GuildDB.factionArmbands)) {
if (description == "") description += `> <@&${factionID}> - ${data.armband}`;
else description += `\n> <@&${factionID}> - *${data.armband}*`;
if (GuildDB.usedArmbands.length == 0) {
description = '> There are no factions that have claimed armbands.';
} else {
for (const [factionID, data] of Object.entries(GuildDB.factionArmbands)) {
if (description == "") description += `> <@&${factionID}> - ${data.armband}`;
else description += `\n> <@&${factionID}> - *${data.armband}*`;
}
}
factions.setDescription(description);
return interaction.send({ embeds: [factions] });
}
// Else return specific faction and their armband.
if (!GuildDB.factionArmbands[args[0].value]) {
return interaction.send({
embeds: [
new EmbedBuilder()
.setColor(client.config.Colors.Yellow)
.setDescription(`**Notice:**\n> The faction <@&${args[0].value}> has not claimed an armband.`)
],
flags: (1 << 6)
});
}
let armbandURL;
for (let i = 0; i < Armbands.length; i++) {
if (Armbands[i].name == GuildDB.factionArmbands[args[0].value].armband) {
armbandURL = Armbands[i].url;
break;
}
}
factions.setDescription(description);
const faction = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`> Faction <@&${GuildDB.factionArmbands[args[0].value].faction}> - ***${GuildDB.factionArmbands[args[0].value].armband}***`)
.setImage(armbandURL);
return interaction.send({ embeds: [factions] });
return interaction.send({ embeds: [faction] });
},
},
Interactions: {}