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:
parent
656fb1baf3
commit
15408b04d7
1 changed files with 4 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue