Require user to be in voice channel

This commit is contained in:
Max Isom 2020-03-19 17:39:55 -05:00
parent 362ce89987
commit 4659717e5f
12 changed files with 42 additions and 9 deletions

View file

@ -8,6 +8,8 @@ import debug from './utils/debug';
import NaturalLanguage from './services/natural-language-commands';
import handleGuildCreate from './events/guild-create';
import handleVoiceStateUpdate from './events/voice-state-update';
import errorMsg from './utils/error-msg';
import {isUserInVoice} from './utils/channels';
@injectable()
export default class {
@ -81,10 +83,15 @@ export default class {
}
try {
handler.execute(msg, args);
if (handler.requiresVC && !isUserInVoice(msg.guild, msg.author)) {
await msg.channel.send(errorMsg('gotta be in a voice channel'));
return;
}
await handler.execute(msg, args);
} catch (error) {
console.error(error);
msg.reply('there was an error trying to execute that command!');
await msg.channel.send(errorMsg('¯\\_(ツ)_/¯'));
}
});