fix /command help message

This commit is contained in:
Romain Beaumont 2015-11-28 02:16:23 +01:00
parent 23094fd152
commit f2889dd674
3 changed files with 12 additions and 10 deletions

View file

@ -11,11 +11,7 @@ module.exports.player=function(player,serv)
{
player._client.on('chat', ({message} = {}) => {
if(message[0]=="/") {
player.behavior('command', {
command: message.slice(1)
}, ({command}) => {
player.handleCommand(command);
});
player.behavior('command', {command: message.slice(1)}, ({command}) => player.handleCommand(command));
}
else {
player.behavior('chat', {

View file

@ -74,7 +74,13 @@ module.exports.player=function(player) {
});
player.handleCommand = (str) => {
player.commands.use(str).catch((err)=> setTimeout(() => {throw err;},0));
};
player.handleCommand = async (str) => {
try {
var res = await player.commands.use(str)
if (res) player.chat('' + res);
}
catch(err) {
setTimeout(() => {throw err;}, 0);
}
}
};

View file

@ -30,7 +30,7 @@ module.exports.player=function(player,serv){
info: 'to change a time to night',
usage: '/night',
action(params) {
player.handleCommand('time set night');
return player.handleCommand('time set night');
}
});
@ -69,7 +69,7 @@ module.exports.player=function(player,serv){
info: 'to change a time to day',
usage: '/day',
action(params) {
player.handleCommand('time set day');
return player.handleCommand('time set day');
}
});
};