basic claim function

This commit is contained in:
SowinskiBraeden committed 2022-12-07 14:10:53 -08:00
1 parent d3264d4cfc
commit 8cbb3efd12
6 files changed
+223 -146

No files matched your search

+66 -6
View File
@@ -1,4 +1,5 @@
const { ActionRowBuilder, EmbedBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const { ActionRowBuilder, EmbedBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder, InteractionCollector } = require('discord.js');
const { Armbands } = require('../config/armbandsdb.js');
module.exports = { module.exports = {
name: "claim", name: "claim",
@@ -25,17 +26,17 @@ module.exports = {
* @param {string[]} args * @param {string[]} args
* @param {*} param3 * @param {*} param3
*/ */
run: async (client, interaction, args, GuildDB) => { run: async (client, interaction, args, { GuildDB }) => {
if (!interaction.member.roles.includes(args[0].value)) { if (!interaction.member.roles.includes(args[0].value)) {
const invalidRoleEmbed = new EmbedBuilder() const invalidRoleEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Yellow) .setColor(client.config.Colors.Yellow)
.setDescription('**Notice:**\n> You cannot claim an armband for a role you don\'t have.'); .setDescription('**Notice:**\n> You cannot claim an armband for a role you don\'t have.');
return interaction.send({ embeds: [invalidRoleEmbed] }); return interaction.send({ embeds: [invalidRoleEmbed], flags: (1 << 6) });
} }
// If this faction has an existing record in the db // If this faction has an existing record in the db
if (GuildDB.factionArmbads[args[0].value]) { if (GuildDB.factionArmbands[args[0].value]) {
const warnArmbadChange = new EmbedBuilder() const warnArmbadChange = new EmbedBuilder()
.setColor(client.config.Colors.Yellow) .setColor(client.config.Colors.Yellow)
.setDescription(`**Notice:**\n> The faction <@&${args[0].value}> already has an armband selected. Are you sure you would like to change this?`) .setDescription(`**Notice:**\n> The faction <@&${args[0].value}> already has an armband selected. Are you sure you would like to change this?`)
@@ -52,16 +53,75 @@ module.exports = {
.setStyle(ButtonStyle.Secondary) .setStyle(ButtonStyle.Secondary)
) )
return interaction.send({ embeds: [warnArmbadChange], components: [opt] }); return interaction.send({ embeds: [warnArmbadChange], components: [opt], flags: (1 << 6) });
} }
return interaction.send({ content: 'debug' }); let available = new SelectMenuBuilder()
.setCustomId(`Claim-${args[0].value}-1-${interaction.member.user.id}`)
.setPlaceholder('Select an armband from list 1 to claim')
let availableNext = new SelectMenuBuilder()
.setCustomId(`Claim-${args[0].value}-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++) {
if (!GuildDB.usedArmbands.includes(Armbands[i].name)) {
tracker++;
data = {
label: Armbands[i].name,
description: 'Select this armband',
value: Armbands[i].name,
}
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 });
}, },
}, },
Interactions: { Interactions: {
Claim: { Claim: {
run: async (client, interaction, GuildDB) => { run: async (client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id))
return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) });
let factionID = interaction.customId.split('-')[1];
let data = {
faction: factionID,
armband: interaction.values[0],
};
client.dbo.collection("guilds").updateOne({'server.serverID': GuildDB.serverID}, {$push: {'server.usedArmbands': interaction.values[0]}, $set: {[`server.factionArmbands.${factionID}`]: data}}, function (err, res) {
if (err) return client.sendInternalError(interacction, err);
})
let armbandURL;
for (let i = 0; i < Armbands.length; i++) {
if (Armbands[i].name == interaction.values[0]) {
armbandURL = Armbands[i].url;
break;
}
}
const success = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`**Success!**\n> The faction <@&${factionID}> has now claimed *${interaction.values[0]}*`)
.setImage(armbandURL);
return interaction.update({ embeds: [success], components: [], flags: 0 });
} }
}, },
+1 -2
View File
@@ -1,5 +1,4 @@
const { EmbedBuilder, ActionRowBuilder, SelectMenuBuilder } = require("discord.js"); const { EmbedBuilder } = require("discord.js");
const settings = require('../config/settingsHelp');
module.exports = { module.exports = {
name: "help", name: "help",
+152
View File
@@ -0,0 +1,152 @@
module.exports = {
Armbands: [
{
name: "Armband (Black)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/8/82/ArmbandBlack.png/revision/latest?cb=20161127174754"
},
{
name: "Armband (Blue)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/b/bd/ArmbandBlue.png/revision/latest?cb=20161127174803"
},
{
name: "Armband (Green)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/ce/ArmbandGreen.png/revision/latest?cb=20161127174812"
},
{
name: "Armband (Orange)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/e6/ArmbandOrange.png/revision/latest?cb=20161127174846"
},
{
name: "Armband (Pink)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/f/f7/ArmbandPink.png/revision/latest?cb=20161127174854"
},
{
name: "Armband (Red)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/1/14/Armband.png/revision/latest?cb=20161127174901"
},
{
name: "Armband (Yellow)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/8/81/ArmbandYellow.png/revision/latest?cb=20161127174918"
},
{
name: "Armband (White)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/c7/Armband_White.png/revision/latest?cb=20161127174926"
},
{
name: "Armband (Altis)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/ee/Flag_alti_co.png/revision/latest?cb=20200820222622"
},
{
name: "Armband (APA)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/c2/Flag_apa_co.png/revision/latest?cb=20200820222623"
},
{
name: "Armband (Bear)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/e1/Flag_bear_co.png/revision/latest?cb=20200820222626"
},
{
name: "Armband (Bohemia)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/ee/Flag_bi_co.png/revision/latest?cb=20200820222627"
},
{
name: "Armband (Brain)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/7/7d/Flag_brain_co.png/revision/latest?cb=20200820222628"
},
{
name: "Armband (CDF)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/d/d6/Flag_cdf_co.png/revision/latest?cb=20200820222629"
},
{
name: "Armband (CHED.)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/9/96/Flag_ched_co.png/revision/latest?cb=20200820222630"
},
{
name: "Armband (CHEL)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/9/98/Flag_chel_co.png/revision/latest?cb=20200820222631"
},
{
name: "Armband (Chernarus)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/ef/Flag_chern_co.png/revision/latest?cb=20200820222632"
},
{
name: "Armband (CMC)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/d/da/Flag_cmc_co.png/revision/latest?cb=20200820222634"
},
{
name: "Armband (Rooster)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/4/44/Flag_cock_co.png/revision/latest?cb=20200820222635"
},
{
name: "Armband (DayZ)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/b/b2/Flag_dayz_co.png/revision/latest?cb=20200820222636"
},
{
name: "Armband (DROS)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/2/24/Flag_dros_co.png/revision/latest?cb=20200820222637"
},
{
name: "Armband (Fawn)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/d/d2/Flag_fawn_co.png/revision/latest/scale-to-width-down/1000?cb=20200820222639"
},
{
name: "Armband (Pirates)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/a/ab/Flag_jolly_co.png/revision/latest?cb=20200820222643"
},
{
name: "Armband (Cannibals)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/4/42/Flag_jolly_c_co.png/revision/latest?cb=20200820222641"
},
{
name: "Armband (KOS)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/a/a1/Flag_kos_co.png/revision/latest?cb=20200820222644"
},
{
name: "Armband (LDF)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/c1/Flag_ldf_co.png/revision/latest?cb=20200820222645"
},
{
name: "Armband (Livonia)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/e6/Flag_livo_co.png/revision/latest?cb=20200820222647"
},
{
name: "Armband (NAPA)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/e4/Flag_napa_co.png/revision/latest?cb=20200820222648"
},
{
name: "Armband (Police)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/6/63/Flag_police_co.png/revision/latest?cb=20200820222649"
},
{
name: "Armband (TEC)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/e/ea/Flag_tec_co.png/revision/latest?cb=20200820222650"
},
{
name: "Armband (UEC)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/ca/Flag_uec_co.png/revision/latest?cb=20200820222651"
},
{
name: "Armband (Wolf)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/b/b2/Flag_wolf_co.png/revision/latest?cb=20200820222653"
},
{
name: "Armband (Zenit)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/0/05/Flag_zenit_co.png/revision/latest?cb=20200820222654"
},
{
name: "Armband (Z-Hunters)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/9/97/Flag_zhunters_co.png/revision/latest?cb=20200820222621"
},
{
name: "Armband (RSTA)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/2/20/Flag_rsta_co.png/revision/latest/scale-to-width-down/1000?cb=20210216191221"
},
{
name: "Armband (Refuge)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/8/8e/Flag_refuge_co.png/revision/latest/scale-to-width-down/1000?cb=20210216191205"
},
{
name: "Armband (Snake)",
url: "https://static.wikia.nocookie.net/dayz_gamepedia/images/5/54/Flag_snake_co.png/revision/latest/scale-to-width-down/1000?cb=20210216191234"
},
]
}
+1 -1
View File
@@ -11,7 +11,7 @@ module.exports = {
Scopes: ["identify", "guilds", "applications.commands"], //Discord OAuth2 Scopes Scopes: ["identify", "guilds", "applications.commands"], //Discord OAuth2 Scopes
IconURL: "", IconURL: "",
Colors: { Colors: {
Default: "#6e5145", Default: "#f05724",
Red: "#ba0f0f", Red: "#ba0f0f",
Green: "#32a852", Green: "#32a852",
Yellow: "#ffb01f" Yellow: "#ffb01f"
-134
View File
@@ -1,134 +0,0 @@
module.exports = {
settings: [
{
name: "allowed_channels",
description: `
If you wish to limit users to use the bot in some channels, you can configure \`allowed_channels\`. To do so, use \`/config allowed_channels add <your channel>\` to add a channel to a list of allowed channels.
To remove a channel, use \`/config allowed_channel remove <your channel>\`.
`
},
{
name: "action_channel",
description: `
To save the hastle of cluttered channels, you can configure a dedicated channel for the \`/action\` command. To do so, use \`/config action_channel set <channel>\`. This will send any output for the \`/action\` command to this channel.
To remove this configuration, use \`/config action_channel remove\`
`
},
{
name: "tweet_channel",
description: `
To save the hastle of cluttered channels, you can configure a dedicated channel for the \`/tweet\` command. To do so, use \`/config tweet_channel set <channel>\`. This will send any output for the \`/tweet\` command to this channel.
To remove this configuration, use \`/config tweet_channel remove\`
`
},
{
name: "adverts_channel",
description: `
Users with the configured commercial role can create advertisements for their commercial business. To keep your channels clean, you can limit the output of this command to a dedicated channel. To do so, use \`/config adverts_channel set <channel>\`. This will send any adverts to this channel.
To remove this configuration, use \`/config adverts_channel remove\`.
`
},
{
name: "dispatcher_channel",
description: `
In order for the \`/311\` or \`/911\` commands to be used, you need to configure two settings. \`dispatcher_channel\` is one of the settings to configure. This will redirect all \`/311\` or \`/911\` reports to a dedicated channel. Use \`/config dispatcher_channel set <channel>\` to configure this setting.
To remove this configuration, use \`/config dispatcher_channel remove\`.
`
},
{
name: "starting_balance",
description: `
New users in your guild receive $1000.00 as their starting balance. This can be configured, use \`/config starting_balance <amount>\`. This can be a floating point number, e.g 150.40
floating point number: a number value with a decimal.
`
},
{
name: "income_role",
description: `
Users can work once a day to earn money, but this will require a role with a set daily income. To configure a new income role, use \`/config income_role set <role> <daily income>\`.
Users with one of these configured roles can use the \`/work\` command once a day to earn their set daily income.
Note: If a user has more than one role to earn income, using the \`/work\` command will earn them the highest income from one of the roles they have.
To remove one of the configured roles, use \`/config income_roles remove <role>\`.
`
},
{
name: "bot_admin_role",
description: `
Some commands are limited to users who can manage the guild (Admin privilages), but if you wish for users without admin privilages to access commands such as \`/config\` \`/money\` or \`/reset\`. You can configure a bot admin role.
Use \`/config bot_admin_role set <role>\` to configure the bot admin role.
To remove this configuration, use \`/config bot_admin_role remove\`.
`
},
{
name: "commercial_role",
description: `
Users with the commercial_role have access to business related commands, to configure this role to give to some users, use \`/config commercial_role set <role>\`.
To remove this configured role, use \`/config commercial_role remove\`.
`
},
{
name: "officer_role",
description: `
The \`/fine\` command requires a user to have a configured officer role. To configure this role, use \`/config officer_role set <role>\`
To remove this configured role, use \`/config officer_role remove\`.
`
},
{
name: "dispatcher_role",
description: `
In order for the \`/311\` or \`/911\` commands to be used, you need to configure two settings. \`dispatcher_role\` is one of the settings to configure. This will allow users to interact with all \`/311\` or \`/911\` reports. Use \`/config dispatcher_role set <role>\` to configure this setting.
To remove this configuration, use \`/config dispatcher_role remove\`.
`
},
{
name: "only_officers_search",
description: `
The \`/search\` command allows users to view other users inventories. If you wish to limit this command, you can do so by configuring \`only_officers_search\`. Use \`/config only_officers_search <true/false>\`. This will optionally limit the \`/search\` command to users with the configured officer role.
`
},
{
name: "can_dismiss_invoices",
description: `
This configurations allows users who have been given an invoice to \`Dismiss & Delete\` an invoice they choose rather than pay. This can be set to false, so users must pay their invoice.\n\n**Note:** Invoices are paid from a users bank balance, and not with their cash balance.
`
},
{
name: "view",
description: `
There is a lot of settings you can configure. To view a all configured settings, use the following: \`/config view\`. This will display all configured settings, and their values if configured.
`
},
{
name: "reset",
description:`
This will reset all configurations back to default settings, clearing all set roles and channels.
`
},
{
name: "casino_multiplier",
description: `
This configurations allows you to customize the multiplier used to determine the winnings from casino games.
`
},
{
name: "work_limiter",
description: `
This configuration allows you to alter the number of hours a user has to wait between the use of the \`/work\` command. By default, users need to wait **24** hours before the can use the \`/work\` command again.
`
}
]
}
+3 -3
View File
@@ -192,10 +192,10 @@ class DayzArmbands extends Client {
getDefaultSettings(GuildId) { getDefaultSettings(GuildId) {
return { return {
serverID: GuildId, serverID: GuildId,
allowedChannels: [], // list of channels the bot is allowed to be used in allowedChannels: [],
factionArmbands: {}, factionArmbands: {},
usedArmbands: [], usedArmbands: [],
botAdmin: null, // botAdmin: null,
} }
} }
@@ -216,7 +216,7 @@ class DayzArmbands extends Client {
return { return {
serverID: GuildId, serverID: GuildId,
customChannelStatus: guild.server.allowedChannels.length > 0 ? true : false, // not stored but calculated after customChannelStatus: guild.server.allowedChannels.length > 0 ? true : false,
allowedChannels: guild.server.allowedChannels, allowedChannels: guild.server.allowedChannels,
factionArmbands: guild.server.factionArmbands, factionArmbands: guild.server.factionArmbands,
usedArmbands: guild.server.usedArmbands, usedArmbands: guild.server.usedArmbands,