mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 23:25:02 +00:00
Add templateFormatter; migrate from formatTemplateString to templateFormatter
This commit is contained in:
parent
19605ea6af
commit
f8ae8a3003
6 changed files with 435 additions and 32 deletions
|
@ -1,4 +1,3 @@
|
|||
import at from "lodash.at";
|
||||
import { Emoji, Guild, GuildAuditLogEntry, TextableChannel } from "eris";
|
||||
import url from "url";
|
||||
import tlds from "tlds";
|
||||
|
@ -78,14 +77,6 @@ export function stripObjectToScalars(obj, includedNested: string[] = []) {
|
|||
return result;
|
||||
}
|
||||
|
||||
const stringFormatRegex = /{([^{}]+?)}/g;
|
||||
export function formatTemplateString(str: string, values) {
|
||||
return str.replace(stringFormatRegex, (match, prop) => {
|
||||
const value = at(values, prop)[0];
|
||||
return typeof value === "string" || typeof value === "number" ? String(value) : "";
|
||||
});
|
||||
}
|
||||
|
||||
export const snowflakeRegex = /[1-9][0-9]{5,19}/;
|
||||
|
||||
const isSnowflakeRegex = new RegExp(`^${snowflakeRegex.source}$`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue