Skip to content

Commit

Permalink
added jsdocs to function
Browse files Browse the repository at this point in the history
  • Loading branch information
200percentmicky committed Oct 5, 2023
1 parent 5aeb167 commit 778bea8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/modules/ChadUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
/// You should have received a copy of the GNU General Public License
/// along with this program. If not, see <https://www.gnu.org/licenses/>.

// 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.
Expand Down Expand Up @@ -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.`);
}
}

Expand Down

0 comments on commit 778bea8

Please sign in to comment.