3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

templateFormatter: add choose() as a shortcut for cases() with a preset index that picks from the cases randomly

This commit is contained in:
Dragory 2019-03-16 18:52:45 +02:00
parent 656fb1baf3
commit 15408b04d7

View file

@ -348,6 +348,10 @@ const baseValues = {
mod = parseInt(mod, 10) - 1;
return cases[Math.max(0, mod % cases.length)];
},
choose(...cases) {
const mod = Math.floor(Math.random() * cases.length) + 1;
return baseValues.cases(mod, ...cases);
},
};
export async function renderTemplate(template: string, values = {}, includeBaseValues = true) {