@globalart/nestcord
Version:
A module for creating Discord bots using NestJS, based on Discord.js
74 lines (73 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandDiscovery = void 0;
const discord_js_1 = require("discord.js");
const context_1 = require("../context");
/**
* Represents a command discovery.
* @abstract
*/
class CommandDiscovery extends context_1.NestCordBaseDiscovery {
/**
* Return the command ID
*/
getId() {
var _a;
return (_a = this.meta.discordResponse) === null || _a === void 0 ? void 0 : _a.id;
}
/**
* Return the discord response of command
*/
getDiscordResponse() {
return this.meta.discordResponse;
}
/**
* Returns the command name.
*/
getName() {
return this.meta.name;
}
/**
* Get command category
*/
getCategory() {
return this.meta.category;
}
/**
* Sets the command guilds for register.
* @param guilds
*/
setGuilds(guilds) {
this.meta.guilds = guilds;
}
/**
* Checks if the command has a guild.
* @param guild
*/
hasGuild(guild) {
var _a, _b;
return (_b = (_a = this.meta.guilds) === null || _a === void 0 ? void 0 : _a.includes(guild)) !== null && _b !== void 0 ? _b : false;
}
/**
* Returns the guilds.
*/
getGuilds() {
return this.meta.guilds;
}
/**
* Get sub commands
*/
getSubCommands() {
if (this.isSlashCommand()) {
return this.subcommands;
}
return new discord_js_1.Collection();
}
hasSubCommands() {
if (this.isSlashCommand()) {
return this.subcommands.size > 0;
}
return false;
}
}
exports.CommandDiscovery = CommandDiscovery;