Error Handling group commands on inactive features.

master
masterhc 9 months ago
parent e9cef23229
commit ddfdb58348

@ -8,7 +8,7 @@ module.exports = class leave extends Command
{
super(client, {
name: 'activateMusic',
group:'music',
group:'admin',
aliases: ['music','amusic'],
description: 'Activates music for the guild. Can be called again to disable.',
needsAdmin:true,

@ -49,6 +49,7 @@ class command
{
this.name = options.name;
this.aliases = options.aliases;
this.group = options.group;
this.description = options.description;
this.needsAdmin =options.needsAdmin;
this.hidden = options.hidden;
@ -74,9 +75,9 @@ class _Client extends Client
if(typeof command === 'function')
{
let c = new command(this);
this.commands.set(c.name,{
needsAdmin: c.needsAdmin?c.needsAdmin:false,
group: c.group,
command: command,
});
if(c.aliases)
@ -85,6 +86,7 @@ class _Client extends Client
{
this.commands.set(c.aliases[i],{
needsAdmin: c.needsAdmin,
group: c.group,
command: command,
});
}
@ -186,7 +188,7 @@ class _Client extends Client
*/
async enableCommands()
{
this.on("messageCreate", message=>
this.on("messageCreate", async (message)=>
{
this.checkForInvites(message);
if(message.content.startsWith(process.env.prefix)) //Test prefix t!
@ -202,7 +204,8 @@ class _Client extends Client
let isMusicRelated = this.commands.get(commandName).group == 'music';
if(isMusicRelated)
{
if(!this.getMusicActive(message.guildId)) return new ErrorMessage(this).send(ErrorType.FeatureInnactive, message);
let isActive = await this.getMusicActive(message.guildId);
if(!isActive) return new ErrorMessage(this).send(ErrorType.FeatureInnactive, message);
}
let isAdmin =false;
try

Loading…
Cancel
Save