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} = {}) => { player._client.on('chat', ({message} = {}) => {
if(message[0]=="/") { if(message[0]=="/") {
player.behavior('command', { player.behavior('command', {command: message.slice(1)}, ({command}) => player.handleCommand(command));
command: message.slice(1)
}, ({command}) => {
player.handleCommand(command);
});
} }
else { else {
player.behavior('chat', { player.behavior('chat', {

View file

@ -74,7 +74,13 @@ module.exports.player=function(player) {
}); });
player.handleCommand = (str) => { player.handleCommand = async (str) => {
player.commands.use(str).catch((err)=> setTimeout(() => {throw err;},0)); 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', info: 'to change a time to night',
usage: '/night', usage: '/night',
action(params) { 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', info: 'to change a time to day',
usage: '/day', usage: '/day',
action(params) { action(params) {
player.handleCommand('time set day'); return player.handleCommand('time set day');
} }
}); });
}; };