sheweny
Version:
The powerful framework for create discord bots
55 lines • 1.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientUtil = void 0;
const resolve_1 = require("@sheweny/resolve");
/**
* Utility methods and properties for the client.
*/
class ClientUtil extends resolve_1.DiscordResolve {
constructor(client) {
super(client);
Object.defineProperty(this, "client", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.client = client;
}
// BUTTONS
getButtons() {
return this.client.collections.buttons.toJSON().flat(1);
}
// COMMANDS
getCommands() {
return this.client.collections.commands
.toJSON()
.map((c) => c.flat(1))
.flat(1);
}
// EVENTS
getEvents() {
return this.client.collections.events.toJSON().flat(1);
}
// INHIBITORS
getInhibitors() {
return this.client.collections.inhibitors.toJSON().flat(1);
}
// SELECT MENUS
getSelectMenus() {
return this.client.collections.selectMenus.toJSON().flat(1);
}
/* Resolve */
resolveCommand(command) {
let cmd = this.client.collections.commands.get(command);
if (cmd) {
return cmd;
}
else {
cmd = this.client.collections.commands.find((cd) => cd.some(c => c.name.startsWith(command) || (c.aliases != undefined && c.aliases.length != 0 && c.aliases.includes(command))));
}
return cmd;
}
}
exports.ClientUtil = ClientUtil;
//# sourceMappingURL=ClientUtil.js.map