From f2889dd674d2d4b69cfe2155d38a029016d86196 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 28 Nov 2015 02:16:23 +0100 Subject: [PATCH] fix /command help message --- src/lib/plugins/chat.js | 6 +----- src/lib/plugins/commands.js | 12 +++++++++--- src/lib/plugins/daycycle.js | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lib/plugins/chat.js b/src/lib/plugins/chat.js index c2f3c9d..8629993 100644 --- a/src/lib/plugins/chat.js +++ b/src/lib/plugins/chat.js @@ -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', { diff --git a/src/lib/plugins/commands.js b/src/lib/plugins/commands.js index 009a88e..9e3ca3f 100644 --- a/src/lib/plugins/commands.js +++ b/src/lib/plugins/commands.js @@ -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); + } + } }; diff --git a/src/lib/plugins/daycycle.js b/src/lib/plugins/daycycle.js index 6c9ffd5..af3ce5a 100644 --- a/src/lib/plugins/daycycle.js +++ b/src/lib/plugins/daycycle.js @@ -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'); } }); }; \ No newline at end of file