diff --git a/src/commands/ban.js b/src/commands/ban.js index 2586dcf..f31794e 100644 --- a/src/commands/ban.js +++ b/src/commands/ban.js @@ -6,6 +6,8 @@ module.exports = { name: "ban", description: "Ban a user", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("ban") diff --git a/src/commands/check.js b/src/commands/check.js index fdd2ea3..6f16e03 100644 --- a/src/commands/check.js +++ b/src/commands/check.js @@ -7,6 +7,8 @@ module.exports = { name: "check", description: "Check a player's stats.", type: "slash", + dev: false, + public: true, data: new SlashCommandBuilder() .setName("check") diff --git a/src/commands/clear.js b/src/commands/clear.js index 68b156b..cfcd984 100644 --- a/src/commands/clear.js +++ b/src/commands/clear.js @@ -5,6 +5,8 @@ module.exports = { name: "clear", description: "Clears messages", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("clear") diff --git a/src/commands/config.js b/src/commands/config.js index 0cbdb43..584af23 100644 --- a/src/commands/config.js +++ b/src/commands/config.js @@ -8,6 +8,7 @@ module.exports = { description: "Configure the bot", type: "slash", dev: true, + public: false, data: new SlashCommandBuilder() .setName("config") diff --git a/src/commands/devel.js b/src/commands/devel.js index d857163..91763be 100644 --- a/src/commands/devel.js +++ b/src/commands/devel.js @@ -4,6 +4,8 @@ module.exports = { name: "admin", description: "Admin command.", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("devel") diff --git a/src/commands/forceunverify.js b/src/commands/forceunverify.js index 0b3b76d..896de0c 100644 --- a/src/commands/forceunverify.js +++ b/src/commands/forceunverify.js @@ -8,6 +8,8 @@ module.exports = { name: "forceunverify", description: "Force unverify a user", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("forceunverify") diff --git a/src/commands/forceupdate.js b/src/commands/forceupdate.js index 8305833..5f17c3f 100644 --- a/src/commands/forceupdate.js +++ b/src/commands/forceupdate.js @@ -9,6 +9,8 @@ module.exports = { name: "forceupdate", description: "Force update the user", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("forceupdate") diff --git a/src/commands/forceverify.js b/src/commands/forceverify.js index 090fff2..1510ba2 100644 --- a/src/commands/forceverify.js +++ b/src/commands/forceverify.js @@ -10,6 +10,8 @@ module.exports = { name: "forceverify", description: "Force verify a user.", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("forceverify") diff --git a/src/commands/guild.js b/src/commands/guild.js index ef1c146..da5f5d7 100644 --- a/src/commands/guild.js +++ b/src/commands/guild.js @@ -7,6 +7,8 @@ module.exports = { name: "guild", description: "Subcommands for guilds", type: "slash", + dev: false, + public: true, data: new SlashCommandBuilder() .setName("guild") diff --git a/src/commands/help.js b/src/commands/help.js index 98ef090..a20595a 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -1,10 +1,13 @@ const { SlashCommandBuilder } = require("discord.js") const { color, devMessage } = require("../../config/options.json") +const fs = require("fs") module.exports = { name: "help", description: "Help command", type: "slash", + dev: true, + public: true, data: new SlashCommandBuilder() .setName("help") @@ -17,8 +20,22 @@ module.exports = { await interaction.deferReply({ ephemeral: true }) - const embedColor = Number(color.replace("#", "0x")) + const commands = [] + const commandFiles = fs.readdirSync(__dirname).filter(file => file.endsWith(".js")) + for (const file of commandFiles) { + const command = require(`./${file}`) + if (command.public) { + commands.push(command) + } + } + const commandList = commands.map((command) => { + return { + name: "**/" + command.name + "**", + value: "`" + command.description + "`" + } + }) + const embedColor = Number(color.replace("#", "0x")) const footerText = interaction.guild ? interaction.guild.name : interaction.user.username + " | " + devMessage const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true }) @@ -26,27 +43,10 @@ module.exports = { embeds: [{ title: "Commands", description: "List of commands", - fields: [ - { - name: "/check", - value: "Check the stats of a player" - }, - { - name: "/reqs", - value: "Check the requirements of the guild" - }, - { - name: "/update", - value: "Update's your roles" - }, - { - name: "/help", - value: "Shows this message" - } - ], + fields: commandList, color: embedColor, thumbnail: { - url: interaction?.guild.iconURL({ dynamic: true }) || null + url: interaction?.guild?.iconURL({ dynamic: true }) || null }, footer: { icon_url: footerIcon, diff --git a/src/commands/kick.js b/src/commands/kick.js index 7ad3840..a7c61cf 100644 --- a/src/commands/kick.js +++ b/src/commands/kick.js @@ -6,6 +6,8 @@ module.exports = { name: "kick", description: "Kick a member from the server.", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("kick") diff --git a/src/commands/ping.js b/src/commands/ping.js index 739e33c..d88d5dc 100644 --- a/src/commands/ping.js +++ b/src/commands/ping.js @@ -5,6 +5,8 @@ module.exports = { name: "ping", description: "Get the bot's ping.", type: "slash", + dev: false, + public: true, data: new SlashCommandBuilder() .setName("ping") diff --git a/src/commands/remove.js b/src/commands/remove.js index e0dcafb..c054f24 100644 --- a/src/commands/remove.js +++ b/src/commands/remove.js @@ -6,6 +6,8 @@ module.exports = { name: "remove", description: "Remove a person on the waiting list.", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("remove") diff --git a/src/commands/reqs.js b/src/commands/reqs.js index 4bd4ae9..74023f6 100644 --- a/src/commands/reqs.js +++ b/src/commands/reqs.js @@ -1,11 +1,14 @@ const { SlashCommandBuilder } = require("discord.js") const { color, devMessage } = require("../../config/options.json") -const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require("../../config/reqs.json") +const { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } = require("../../config/reqs.json") module.exports = { name: "reqs", description: "Displays the requirements for the guild.", type: "slash", + dev: false, + public: true, + data: new SlashCommandBuilder() .setName("reqs") .setDescription("Displays the requirements for the guild."), @@ -26,7 +29,7 @@ module.exports = { description: "**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**", color: embedColor, thumbnail: { - url: interaction.guild.iconURL() + url: interaction?.guild?.iconURL({ dynamic: true }) || null }, fields: [ { @@ -37,7 +40,8 @@ module.exports = { }, { name: "**Skywars**", - value: "**Stars:** `" + swstars.toString() + "`" + value: "**Stars:** `" + swstars.toString() + + "`\n**KDR:** `" + swkdr.toString() + "`" }, { name: "**Duels**", diff --git a/src/commands/send.js b/src/commands/send.js index 0c571b2..cb02a0d 100644 --- a/src/commands/send.js +++ b/src/commands/send.js @@ -5,6 +5,8 @@ module.exports = { name: "send", description: "Send a message to a channel.", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("send") diff --git a/src/commands/setnick.js b/src/commands/setnick.js index a727ce9..02acf77 100644 --- a/src/commands/setnick.js +++ b/src/commands/setnick.js @@ -4,6 +4,8 @@ module.exports = { name: "setnick", description: "Set your nickname", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("setnick") diff --git a/src/commands/setup.js b/src/commands/setup.js index a972823..492e44a 100644 --- a/src/commands/setup.js +++ b/src/commands/setup.js @@ -6,6 +6,7 @@ module.exports = { description: "Used for setup of the bot.", type: "slash", dev: true, + public: false, data: new SlashCommandBuilder() .setName("setup") diff --git a/src/commands/slowmode.js b/src/commands/slowmode.js index f0b6eb2..6e4e69e 100644 --- a/src/commands/slowmode.js +++ b/src/commands/slowmode.js @@ -5,6 +5,8 @@ module.exports = { name: "slowmode", description: "Set the slowmode of a channel.", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("slowmode") diff --git a/src/commands/timeout.js b/src/commands/timeout.js index d7b4a31..e7e9633 100644 --- a/src/commands/timeout.js +++ b/src/commands/timeout.js @@ -6,6 +6,8 @@ module.exports = { name: "timeout", description: "Times out a memeber", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("timeout") diff --git a/src/commands/unban.js b/src/commands/unban.js index d4a4636..288e94e 100644 --- a/src/commands/unban.js +++ b/src/commands/unban.js @@ -5,6 +5,8 @@ module.exports = { name: "unban", description: "Unban a user from the server", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("unban") diff --git a/src/commands/update.js b/src/commands/update.js index d444018..22b9f89 100644 --- a/src/commands/update.js +++ b/src/commands/update.js @@ -9,6 +9,8 @@ module.exports = { name: "update", description: "Update your guild rank.", type: "slash", + dev: false, + public: true, data: new SlashCommandBuilder() .setName("update") diff --git a/src/commands/uuid.js b/src/commands/uuid.js index 9b157db..6f64dd4 100644 --- a/src/commands/uuid.js +++ b/src/commands/uuid.js @@ -6,6 +6,8 @@ module.exports = { name: "uuid", description: "Get a player's UUID", type: "slash", + dev: false, + public: true, data: new SlashCommandBuilder() .setName("uuid") diff --git a/src/commands/verify.js b/src/commands/verify.js index 1a80723..e10fbca 100644 --- a/src/commands/verify.js +++ b/src/commands/verify.js @@ -9,6 +9,8 @@ module.exports = { name: "verify", description: "Verify yourself as a member of the server.", type: "slash", + dev: false, + public: true, data: new SlashCommandBuilder() .setName("verify") diff --git a/src/commands/whois.js b/src/commands/whois.js index db77911..0d6fe0d 100644 --- a/src/commands/whois.js +++ b/src/commands/whois.js @@ -7,6 +7,8 @@ module.exports = { name: "whois", description: "Get's the ign of a user.", type: "slash", + dev: false, + public: false, data: new SlashCommandBuilder() .setName("whois") diff --git a/src/index.js b/src/index.js index b29f3a9..b1d4e20 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,7 @@ const { Client, GatewayIntentBits, Partials, Collection } = require("discord.js") const { loadSlashCommandsEvents, loadContextMenuEvents, loadModalEvents, loadButtonEvents, loadEvents, loadAutocompleteEvents } = require("./utils/eventHandler.js") const { autoDeployCommands } = require("./utils/autodeploy.js") +const { init } = require("./utils/init.js") require("dotenv").config() const mongoURI = process.env.MONGOURI const { connect } = require("mongoose") @@ -26,6 +27,7 @@ client.commands = new Collection() client.events = new Collection() client.modals = new Collection() +init() loadSlashCommandsEvents(client) loadAutocompleteEvents(client) loadContextMenuEvents(client) diff --git a/src/utils/init.js b/src/utils/init.js new file mode 100644 index 0000000..85a7ff3 --- /dev/null +++ b/src/utils/init.js @@ -0,0 +1,38 @@ +const envars = [ + "TOKEN", + "MONGOURI", + "DEV", + "HYPIXELAPIKEY" +] +const devenvars = [ + "DEVTOKEN", + "CLIENTID", + "DEVID", + "GUILDID" +] + +function init() { + if (process.env.NODe_ENV !== "dev") { + for (const envar of envars) { + if (!process.env[envar]) { + console.error(`Missing ${envar} environment variable!`) + process.exit(1) + } + } + } else { + for (const envar of envars) { + if (!process.env[envar]) { + console.error(`Missing ${envar} environment variable!`) + process.exit(1) + } + } + for (const envar of devenvars) { + if (!process.env[envar]) { + console.error(`Missing ${envar} environment variable!`) + process.exit(1) + } + } + } +} + +module.exports = { init }