From ab2b59ff119fd6515b918c12e7b3b460b477ddc9 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Sun, 10 Sep 2023 00:41:45 -0700 Subject: [PATCH] refactor/declare command option types --- commands/admin.js | 55 +++++++++++++++--------- commands/alarm.js | 49 ++++++++++----------- commands/bank.js | 11 ++--- commands/bounty.js | 13 +++--- commands/claim.js | 3 +- commands/config.js | 87 +++++++++++++++++++------------------- commands/event.js | 13 +++--- commands/factions.js | 3 +- commands/gamertag-link.js | 3 +- commands/help.js | 11 ++--- commands/leaderboard.js | 5 ++- commands/lookup.js | 9 ++-- commands/player-stats.js | 7 +-- commands/purchase-uav.js | 5 ++- commands/reset.js | 3 +- config/config.js | 2 +- structures/DayzRBot.js | 4 +- util/CommandOptionTypes.js | 15 +++++++ 18 files changed, 170 insertions(+), 128 deletions(-) create mode 100644 util/CommandOptionTypes.js diff --git a/commands/admin.js b/commands/admin.js index 4bf62a9..1c875f0 100644 --- a/commands/admin.js +++ b/commands/admin.js @@ -1,4 +1,5 @@ const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const bitfieldCalculator = require('discord-bitfield-calculator'); const { BanPlayer, UnbanPlayer, RestartServer, CheckServerStatus } = require('../util/NitradoAPI'); const { Armbands } = require('../config/armbandsdb.js'); @@ -17,92 +18,92 @@ module.exports = { name: "gamertag-link", description: "link a gamertag for a user", value: "gamertag-link", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "user", description: "User to link gamertag to", value: "user", - type: 6, + type: CommandOptions.User, required: true, }, { name: "gamertag", description: "Gamertag of player", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }] }, { name: "gamertag-unlink", description: "unlink a gamertag for a user", value: "gamertag-unlink", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "user", description: "User to link gamertag to", value: "user", - type: 6, + type: CommandOptions.User, required: true, }] }, { name: "claim-armband", description: "Claim an armband for a faction", value: "claim-armband", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "faction_role", description: "Claim an armband for this faction role.", value: "faction_role", - type: 8, + type: CommandOptions.Role, required: true, }] }, { name: "bounty-clear", description: "clear a bounty off a player", value: "bounty-clear", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "Gamertag of player", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }] }, { name: "ban-player", description: "Ban a player from the DayZ server", value: "ban-player", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "gamertag of the player to ban.", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }] }, { name: "unban-player", description: "Unban a player from the DayZ server", value: "unban-player", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "gamertag of the player to unban.", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }] }, { name: "add-money", description: "Add money to user", value: "add", - type: 1, + type: CommandOptions.SubCommand, options: [ { name: "amount", description: "The amount to add to balance", value: "amount", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, @@ -110,7 +111,7 @@ module.exports = { name: "to", description: "User to alter balance", value: "to", - type: 6, + type: CommandOptions.User, required: true, }, ] @@ -119,13 +120,13 @@ module.exports = { name: "remove-money", description: "Remove or remove money from a user", value: "remove", - type: 1, + type: CommandOptions.SubCommand, options: [ { name: "amount", description: "The amount to add to balance", value: "amount", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, @@ -133,7 +134,7 @@ module.exports = { name: "from", description: "User to alter balance", value: "from", - type: 6, + type: CommandOptions.User, required: true, }, ] @@ -141,12 +142,24 @@ module.exports = { name: "restart", description: "Restart the DayZ Server", value: "restart", - type: 1, + type: CommandOptions.SubCommand, }, { name: "auto-restart", description: "Enable/Disable periodic server checks and restart if stopped.", value: "auto-restart", - type: 1, + type: CommandOptions.SubCommand, + }, { + name: "combat-log-timer", + description: "Set the number of minutes to elapse for a player to not combat log. (Set to 0 to disbable combat logging detection)", + value: "combat-log-timer", + type: CommandOptions.SubCommand, + options: [{ + name: "minutes", + description: "Minutes to qualify combat log", + value: 5, + type: CommandOptions.Integer, // Integer + + }] }], SlashCommand: { /** diff --git a/commands/alarm.js b/commands/alarm.js index e378c14..cf52ca4 100644 --- a/commands/alarm.js +++ b/commands/alarm.js @@ -1,4 +1,5 @@ const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const bitfieldCalculator = require('discord-bitfield-calculator'); module.exports = { @@ -16,13 +17,13 @@ module.exports = { name: "create", description: "Create a new Zone Ping Alarm", value: "create", - type: 1, + type: CommandOptions.SubCommand, options: [ { name: "x-coord", description: "X Coordinate of the origin", value: "x-coord", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, @@ -30,7 +31,7 @@ module.exports = { name: "y-coord", description: "Y Coordinate of the origin", value: "y-coord", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, @@ -38,7 +39,7 @@ module.exports = { name: "radius", description: "Radius of Zone Alarm", value: "radius", - type: 10, + type: CommandOptions.Float, min_value: 25.00, required: true, }, @@ -46,14 +47,14 @@ module.exports = { name: "name", description: "Zone Alarm Name", value: "name", - type: 3, + type: CommandOptions.String, required: true, }, { name: "channel", description: "The channel to configure", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }, @@ -61,21 +62,21 @@ module.exports = { name: "role", description: "Role to Ping on Zone Alarm", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }, { name: "emp-exempt", description: "Is this Alarm Exempt to EMP Attacks?", value: false, - type: 5, + type: CommandOptions.Boolean, required: false, }, { name: "show-player-coords", description: "Show a players coords when in the zone", value: true, - type: 5, + type: CommandOptions.Boolean, required: false, } ] @@ -84,18 +85,18 @@ module.exports = { name: "delete", description: "Delete a Zone Alarm", value: "delete", - type: 1, + type: CommandOptions.SubCommand, }, { name: "add-player", description: "Add Player to be Ignored in a Zone Alarm Pings", value: "add-player", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "Gamertag of Player to Ignore", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }] }, @@ -103,12 +104,12 @@ module.exports = { name: "remove-player", description: "Remove a Player from being Ignored in a Zone Alarm Pings", value: "remove-player", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "Gamertag of Player to Ignore", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }] }, @@ -116,24 +117,24 @@ module.exports = { name: "disable", description: "Disable an Zone Alarm", value: "disable", - type: 1, + type: CommandOptions.SubCommand, }, { name: "enable", description: "Enable an Zone Alarm", value: "enable", - type: 1, + type: CommandOptions.SubCommand, }, { name: "set-rule", description: "Add a Rule to an Alarm", value: "set-rule", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "rule", description: "Rule to Add to an Alarm", value: "rule", - type: 3, + type: CommandOptions.String, required: true, choices: [ { name: 'Ban on Entry', value: 'ban_on_entry' }, @@ -145,18 +146,18 @@ module.exports = { name: "remove-rule", description: "Remove a Rule from an Alarm", value: "remove-rule", - type: 1, + type: CommandOptions.SubCommand, }, { name: "rename", description: "Rename an Alarm", value: "rename", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "name", description: "New Alarm Name", value: "name", - type: 3, + type: CommandOptions.String, required: true, }] }, @@ -164,12 +165,12 @@ module.exports = { name: "move-origin", description: "Move an alarms origin to new coordinates", value: "move-origin", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "x-coord", description: "X Coordinate of the origin", value: "x-coord", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, @@ -177,7 +178,7 @@ module.exports = { name: "y-coord", description: "Y Coordinate of the origin", value: "y-coord", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }] diff --git a/commands/bank.js b/commands/bank.js index c3c8a42..983d208 100644 --- a/commands/bank.js +++ b/commands/bank.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const { User, addUser } = require('../structures/user'); module.exports = { @@ -16,12 +17,12 @@ module.exports = { name: "balance", description: "View your bank balance and count your cash", value: "balance", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "user", description: "User to view ballance", value: "user", - type: 6, + type: CommandOptions.User, required: false, }] }, @@ -29,20 +30,20 @@ module.exports = { name: "transfer", description: "Transfer directly to users bank", value: "transfer", - type: 1, + type: CommandOptions.SubCommand, options: [ { name: "user", description: "User to transfer to", value: "user", - type: 6, + type: CommandOptions.User, required: true, }, { name: "amount", description: "The amount to transfer", value: "amount", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, diff --git a/commands/bounty.js b/commands/bounty.js index fdbd42d..33fe865 100644 --- a/commands/bounty.js +++ b/commands/bounty.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; module.exports = { name: "bounty", @@ -14,37 +15,37 @@ module.exports = { name: "set", description: "Set a bounty on a player", value: "set", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "Gamertag of player for bounty", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }, { name: "value", description: "Amount of the bounty", value: "value", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true }, { name: "anonymous", description: "Make this bounty anonymous", value: false, - type: 5, + type: CommandOptions.Boolean, required: false }] }, { name: "pay", description: "Pay off your bounty (double price)", value: "pay", - type: 1, + type: CommandOptions.SubCommand, }, { name: "view", description: "View all active bounties", value: "view", - type: 1, + type: CommandOptions.SubCommand, }], SlashCommand: { /** diff --git a/commands/claim.js b/commands/claim.js index 697ade0..ca0d55f 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -1,4 +1,5 @@ const { ActionRowBuilder, EmbedBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const { Armbands } = require('../config/armbandsdb.js'); module.exports = { @@ -15,7 +16,7 @@ module.exports = { name: "faction_role", description: "Claim an armband for this faction role.", value: "faction_role", - type: 8, + type: CommandOptions.Role, required: true, }], SlashCommand: { diff --git a/commands/config.js b/commands/config.js index 46001ab..bf6c15d 100644 --- a/commands/config.js +++ b/commands/config.js @@ -1,4 +1,5 @@ const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const bitfieldCalculator = require('discord-bitfield-calculator'); module.exports = { @@ -16,18 +17,18 @@ module.exports = { name: "allowed_channels", description: "Set channels you're allowed to use the bot in", value: "allowed_channels", - type: 2, + type: CommandOptions.SubCommandGroup, options: [ { name: "add", description: "Add channel", value: "add", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "channel", description: "The channel to configure", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }] @@ -36,12 +37,12 @@ module.exports = { name: "remove", description: "Remove channel", value: "remove", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "channel", description: "The channel to configure", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }] @@ -52,12 +53,12 @@ module.exports = { name: "killfeed_channel", description: "Set the Killfeed Channel", value: "killfeed_channel", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "channel", description: "The channel to configure", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }] @@ -66,12 +67,12 @@ module.exports = { name: "admin_logs_channel", description: "Set the Admin Logs Channel", value: "admin_logs_channel", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "channel", description: "The channel to configure", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }] @@ -80,12 +81,12 @@ module.exports = { name: "welcome_channel", description: "Set the channel for users to gain access", value: "welcome_channel", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "channel", description: "The channel to configure", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }] @@ -94,12 +95,12 @@ module.exports = { name: "active_players_channel", description: "Set the channel for active players update", value: "active_players_channel", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "channel", description: "The channel to configure", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }] @@ -108,12 +109,12 @@ module.exports = { name: "linked_gt_role", description: "Access Role to give to users", value: "linked_gt_role", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "role", description: "Role to configure", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }] }, @@ -121,12 +122,12 @@ module.exports = { name: "member_role", description: "Role to give users when they join.", value: "member_role", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "role", description: "Role to configure", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }] }, @@ -134,13 +135,13 @@ module.exports = { name: "bot_admin_role", description: "Set/remove bot admin role", value: "bot_admin_role", - type: 1, + type: CommandOptions.SubCommand, options: [ { name: "action", description: "Add or remove a role from the exclude list.", value: "action", - type: 3, + type: CommandOptions.String, choices: [ { name: 'add', value: 'add' }, { name: 'remove', value: 'remove' }, ], @@ -150,7 +151,7 @@ module.exports = { name: "role", description: "Role to configure", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }, ] @@ -159,12 +160,12 @@ module.exports = { name: "admin_role", description: "Discord Server's dedicated admin role", value: "admin_role", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "role", description: "Role to configure", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }] }, @@ -172,13 +173,13 @@ module.exports = { name: "exclude", description: "Exclude roles from users to use to claim a flag.", value: "exclude", - type: 1, + type: CommandOptions.SubCommand, options: [ { name: "action", description: "Add or remove a role from the exclude list.", value: "action", - type: 3, + type: CommandOptions.String, choices: [ { name: 'add', value: 'add' }, { name: 'remove', value: 'remove' }, ], @@ -188,7 +189,7 @@ module.exports = { name: "role", description: "The role to manage", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }, ] @@ -197,24 +198,24 @@ module.exports = { name: "reset", description: "Restore all settings to default configurations", value: "reset", - type: 1, + type: CommandOptions.SubCommand, }, { name: "view", description: "View current settings configuration", value: "view", - type: 1, + type: CommandOptions.SubCommand, }, { name: "starting_balance", description: "Set the starting balance", value: "starting_balance", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "amount", description: "The amount to set the starting balance", value: "amount", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }] @@ -223,12 +224,12 @@ module.exports = { name: "uav-price", description: "Configure the price of a UAV", value: "uav-price", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "amount", description: "The amount to set the UAV price", value: "amount", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }] @@ -237,12 +238,12 @@ module.exports = { name: "emp-price", description: "Configure the price of an EMP", value: "emp-price", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "amount", description: "The amount to set the EMP price", value: "amount", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }] @@ -251,26 +252,26 @@ module.exports = { name: "income_role", description: "Add/update a role to earn income on /collect-income command", value: "set_income_role", - type: 2, + type: CommandOptions.SubCommandGroup, options: [ { name: "set", description: "Set role", value: "set", - type: 1, + type: CommandOptions.SubCommand, options: [ { name: "role", description: "Role to set", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }, { name: "amount", description: "The amount to collect", value: 120.00, - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, } @@ -280,12 +281,12 @@ module.exports = { name: "remove", description: "Remove role", value: "remove", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "role", description: "Role to remove", value: "role", - type: 8, + type: CommandOptions.Role, required: true, }] }, @@ -295,12 +296,12 @@ module.exports = { name: "income_limiter", description: "Change the number of hours to wait before collecting income", value: "income_limiter", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "hours", description: "Number of hours till income can be collected", value: 168.00, // 1 week - type: 10, + type: CommandOptions.Float, required: true, }] }, @@ -308,12 +309,12 @@ module.exports = { name: "show_killfeed_coords", description: "Show the coordinates of the killer or victim in the killfeed channel.", value: "show_killfeed_coords", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "configuration", description: "True or False", value: false, - type: 5, + type: CommandOptions.Boolean, required: true, }] } diff --git a/commands/event.js b/commands/event.js index f9aaa0b..6dc3728 100644 --- a/commands/event.js +++ b/commands/event.js @@ -1,4 +1,5 @@ const { EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const bitfieldCalculator = require('discord-bitfield-calculator'); module.exports = { @@ -15,19 +16,19 @@ module.exports = { name: "player-track", description: "track a player and announce location", value: "player-track", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "Gamertag of player", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }, { name: "time", description: "duration of tracking", value: "time", - type: 4, + type: CommandOptions.Integer, required: true, choices: [ { name: '30-minutes', value: 30 }, { name: '60-minutes', value: 60 }, { name: '90-minutes', value: 90 }, { name: '120-minutes', value: 120 }, @@ -37,14 +38,14 @@ module.exports = { name: "event-name", description: "name of the event", value: "event-name", - type: 3, + type: CommandOptions.String, required: true, }, { name: "channel", description: "channel to host event", value: "channel", - type: 7, + type: CommandOptions.Channel, channel_types: [0], // Restrict to text channel required: true, }] @@ -52,7 +53,7 @@ module.exports = { name: "delete", description: "delete an active event", value: "delete", - type: 1 + type: CommandOptions.SubCommand }], SlashCommand: { /** diff --git a/commands/factions.js b/commands/factions.js index 4d5c635..94a10fd 100644 --- a/commands/factions.js +++ b/commands/factions.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const { Armbands } = require('../config/armbandsdb.js'); module.exports = { @@ -15,7 +16,7 @@ module.exports = { name: "faction_role", description: "View a specific faction's armband by role", value: "faction_role", - type: 8, + type: CommandOptions.Role, required: false, }], SlashCommand: { diff --git a/commands/gamertag-link.js b/commands/gamertag-link.js index 0517660..c97ef56 100644 --- a/commands/gamertag-link.js +++ b/commands/gamertag-link.js @@ -1,4 +1,5 @@ const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; module.exports = { name: "gamertag-link", @@ -14,7 +15,7 @@ module.exports = { name: "gamertag", description: "Gamertag of player", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }], SlashCommand: { diff --git a/commands/help.js b/commands/help.js index 4e2cf98..b57ffd8 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require("discord.js"); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; module.exports = { name: "help", @@ -15,12 +16,12 @@ module.exports = { name: "commands", description: "List all commands", value: "commands", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "command", description: "Get information on a specific command", value: "command", - type: 3, + type: CommandOptions.String, required: false, }] }, @@ -28,19 +29,19 @@ module.exports = { name: "support", description: "Get support for Applicatz", value: "support", - type: 1, + type: CommandOptions.SubCommand, }, { name: "credits", description: "DayZR Bot Credits", value: "credits", - type: 1, + type: CommandOptions.SubCommand, }, { name: "stats", description: "Current Bot Statistics", value: "stats", - type: 1, + type: CommandOptions.SubCommand, } ], SlashCommand: { diff --git a/commands/leaderboard.js b/commands/leaderboard.js index 0ed18ce..c7cf038 100644 --- a/commands/leaderboard.js +++ b/commands/leaderboard.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; module.exports = { name: "leaderboard", @@ -14,7 +15,7 @@ module.exports = { name: "category", description: "Leaderboard Category", value: "category", - type: 3, + type: CommandOptions.String, required: true, choices: [ { name: "money", value: "money" }, @@ -33,7 +34,7 @@ module.exports = { name: "limit", description: "leaderboard limit", value: "limit", - type: 4, + type: CommandOptions.Integer, min_value: 1, max_value: 25, required: true, diff --git a/commands/lookup.js b/commands/lookup.js index 5b5207f..3c08a5c 100644 --- a/commands/lookup.js +++ b/commands/lookup.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; module.exports = { name: "lookup", @@ -14,24 +15,24 @@ module.exports = { name: "discord", description: "Find a Discord user from a Gamertag", value: "discord", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "gamertag", description: "Gamertag of player", value: "gamertag", - type: 3, + type: CommandOptions.String, required: true, }] }, { name: "gamertag", description: "Find a Gamertag from a Discord user", value: "gamertag", - type: 1, + type: CommandOptions.SubCommand, options: [{ name: "user", description: "Discord User", value: "user", - type: 6, + type: CommandOptions.User, required: true, }] }], diff --git a/commands/player-stats.js b/commands/player-stats.js index 395abb4..21dc371 100644 --- a/commands/player-stats.js +++ b/commands/player-stats.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; module.exports = { name: "player-stats", @@ -14,7 +15,7 @@ module.exports = { name: "category", description: "Leaderboard Category", value: "category", - type: 3, + type: CommandOptions.String, required: true, choices: [ { name: "money", value: "money" }, @@ -33,12 +34,12 @@ module.exports = { name: "discord", description: "discord user to lookup stats", value: "discord", - type: 6, + type: CommandOptions.User, required: false, }, { name: "gamertag", description: "gamertag to lookup stats", - type: 3, + type: CommandOptions.String, required: false, }], SlashCommand: { diff --git a/commands/purchase-uav.js b/commands/purchase-uav.js index 6f26523..a8a55d3 100644 --- a/commands/purchase-uav.js +++ b/commands/purchase-uav.js @@ -1,4 +1,5 @@ const { EmbedBuilder } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const { User, addUser } = require('../structures/user') module.exports = { @@ -16,7 +17,7 @@ module.exports = { name: "x-coord", description: "X Coordinate of the origin", value: "x-coord", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, @@ -24,7 +25,7 @@ module.exports = { name: "y-coord", description: "Y Coordinate of the origin", value: "y-coord", - type: 10, + type: CommandOptions.Float, min_value: 0.01, required: true, }, diff --git a/commands/reset.js b/commands/reset.js index 0ff57f1..a04ce07 100644 --- a/commands/reset.js +++ b/commands/reset.js @@ -1,4 +1,5 @@ const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; const { addUser } = require('../structures/user'); const bitfieldCalculator = require('discord-bitfield-calculator'); @@ -16,7 +17,7 @@ module.exports = { name: "user", description: "User to reset", value: "user", - type: 6, + type: CommandOptions.User, required: true, }], SlashCommand: { diff --git a/config/config.js b/config/config.js index b3f839b..aaf1d4c 100644 --- a/config/config.js +++ b/config/config.js @@ -27,7 +27,7 @@ module.exports = { mongoURI: process.env.mongoURI || "mongodb://localhost:27017", dbo: process.env.dbo || "knoldus", Presence: { - type: 3, // Watching, Playing = 0, Streaming = 1, Listening = 2, Custom = 4, Competing = 5 + type: CommandOptions.String, // Watching, Playing = 0, Streaming = 1, Listening = 2, Custom = 4, Competing = 5 name: "DayZ Logs", // What message you want after type status: "online", // You can show either "idle", "dnd", "online", or "offline" }, diff --git a/structures/DayzRBot.js b/structures/DayzRBot.js index e466d81..ee57960 100644 --- a/structures/DayzRBot.js +++ b/structures/DayzRBot.js @@ -78,7 +78,7 @@ class DayzRBot extends Client { return await rest.post(Routes.interactionCallback(interaction.id, interaction.token), { body: { - type: 4, + type: CommandOptions.Integer, data: message, } }); @@ -391,7 +391,7 @@ class DayzRBot extends Client { autoRestart: 0, allowedChannels: [], killfeedChannel: "", - showKillfeedCoords: false, + showKillfeedCoords: 0, connectionLogsChannel: "", activePlayersChannel: "", welcomeChannel: "", diff --git a/util/CommandOptionTypes.js b/util/CommandOptionTypes.js new file mode 100644 index 0000000..716b2cb --- /dev/null +++ b/util/CommandOptionTypes.js @@ -0,0 +1,15 @@ +module.exports = { + CommandOptionTypes: { + SubCommand: 1, + SubCommandGroup: 2, + String: 3, + Integer: 4, + Boolean: 5, + User: 6, + Channel: 7, + Role: 8, + Mentionable: 9, + Float: 10, // AKA Number in Discord's Documentation + Attachment: 11, + } +}; \ No newline at end of file