mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
map + get_snowflake
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
c44d6b97fe
commit
c6f838f333
1 changed files with 10 additions and 0 deletions
|
@ -465,6 +465,12 @@ const baseValues = {
|
|||
if (isNaN(base) || isNaN(power)) return 0;
|
||||
return Math.pow(parseFloat(base), parseFloat(power));
|
||||
},
|
||||
map(obj, key) {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((tobj) => tobj[key]);
|
||||
}
|
||||
return obj[key];
|
||||
},
|
||||
cases(mod, ...cases) {
|
||||
if (cases.length === 0) return "";
|
||||
if (isNaN(mod)) return "";
|
||||
|
@ -475,6 +481,10 @@ const baseValues = {
|
|||
const mod = Math.floor(Math.random() * cases.length) + 1;
|
||||
return baseValues.cases(mod, ...cases);
|
||||
},
|
||||
get_snowflake(str) {
|
||||
if (!str || typeof str !== "string") return "";
|
||||
return str.replaceAll(/[^\d]+/g, "");
|
||||
},
|
||||
};
|
||||
|
||||
export async function renderTemplate(
|
||||
|
|
Loading…
Add table
Reference in a new issue