From 778bea818de3d33870291dcfa0eef69d0b688fb7 Mon Sep 17 00:00:00 2001 From: 200percentmicky Date: Thu, 5 Oct 2023 03:33:54 -0500 Subject: [PATCH] added jsdocs to function --- src/modules/ChadUtils.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/modules/ChadUtils.js b/src/modules/ChadUtils.js index 5eeb5172..c5a26bdb 100644 --- a/src/modules/ChadUtils.js +++ b/src/modules/ChadUtils.js @@ -14,8 +14,10 @@ /// You should have received a copy of the GNU General Public License /// along with this program. If not, see . -// eslint-disable-next-line no-unused-vars -const { Client, GuildMember, BaseGuildVoiceChannel, PermissionsBitField } = require('discord.js'); +/* eslint-disable no-unused-vars */ +const { Client, GuildMember, BaseGuildVoiceChannel, PermissionsBitField, Message } = require('discord.js'); +const { CommandContext } = require('slash-create'); +/* eslint-enable no-unused-vars */ /** * A set of custom utilities for the bot to use. @@ -55,12 +57,21 @@ class ChadUtils { return permission; } + /** + * Attempts to execute a standard prefix command. + * + * @param {Message|CommandContext} message The message object or an instance of `CommandContext`. + * @param {string} commandName The name of the command. + * @param {Object} args Arguments to pass to the command. + * @returns The execution of the prefix command. + * @throws Command not found. + */ static async runPrefixCommand (message, commandName, args) { try { const command = await message.channel.client.commands.findCommand(commandName); return command.exec(message, args); } catch { - throw new Error(`${commandName} is not a registered command.`); + throw new Error(`Command ${commandName} not found.`); } }