Support /astro avec noms partiels ou numériques

=> fix /astro Château Dromant
=> support /astro chat
=> support /astro 12
This commit is contained in:
Vincent Vandemeulebrouck
2021-06-04 18:30:06 +02:00
parent 3a8a8fa5fb
commit 080a8b51b3
3 changed files with 39 additions and 10 deletions

View File

@ -79,9 +79,11 @@ export class RdDCommands {
<br><strong>/payer 10d</strong> permet d'envoyer un message pour payer 10 deniers`
});
rddCommands.registerCommand({
path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(params[0]),
descr: `Affiche les heures de chance et de malchance selon l'heure de naissance donnée en argument. Exemples:
<br><strong>/astro Lyre</strong>`
path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(RdDCommands.toParamString(params)),
descr: `Affiche les heures de chance et de malchance selon l'heure de naissance donnée en argument. Exemples pour l'heure de la Lyre:
<br><strong>/astro 7</strong>
<br><strong>/astro Lyre</strong>
<br><strong>/astro Lyr</strong>`
});
rddCommands.registerCommand({
@ -109,6 +111,10 @@ export class RdDCommands {
this.commandsTable = {};
}
static toParamString(params) {
return params.length == 1 ? params[0] : params.reduce((a, b) => `${a} ${b}`, '');
}
/* -------------------------------------------- */
registerCommand(command) {
this._addCommand(this.commandsTable, command.path, '', command);