diff --git a/backend/src/plugins/Tags/templateFunctions.ts b/backend/src/plugins/Tags/templateFunctions.ts index 67a49069..e0f20ca4 100644 --- a/backend/src/plugins/Tags/templateFunctions.ts +++ b/backend/src/plugins/Tags/templateFunctions.ts @@ -107,6 +107,20 @@ export const TemplateFunctions: TemplateFunction[] = [ arguments: ["string"], examples: ['upperFirst("hello World")'], }, + { + name: "strlen", + description: "Returns the length of a string argument", + returnValue: "number", + arguments: ["string"], + examples: ['strlen("Hello World")'], + }, + { + name: "arrlen", + description: "Returns the length of an array argument", + returnValue: "number", + arguments: ["array"], + examples: ['arrlen(["Hello", "World"])'], + }, { name: "rand", description: "Returns a random number between from and to, optionally using seed", @@ -121,6 +135,20 @@ export const TemplateFunctions: TemplateFunction[] = [ arguments: ["number", "decimalPlaces"], examples: ["round(1.2345, 2)"], }, + { + name: "ceil", + description: "Rounds a number up to the next integer", + returnValue: "number", + arguments: ["number"], + examples: ["ceil(1.2345)"], + }, + { + name: "floor", + description: "Rounds a number down to the next integer", + returnValue: "number", + arguments: ["number"], + examples: ["floor(1.2345)"], + }, { name: "add", description: "Adds two or more numbers", @@ -149,6 +177,13 @@ export const TemplateFunctions: TemplateFunction[] = [ arguments: ["number1", "number2", "..."], examples: ["div(6, 2)"], }, + { + name: "exp", + description: "Raises a number to the power of another number", + returnValue: "number", + arguments: ["base", "power"], + examples: ["exp(2, 3)"], + }, { name: "cases", description: "Returns the argument at position", @@ -163,4 +198,137 @@ export const TemplateFunctions: TemplateFunction[] = [ arguments: ["argument1", "argument2", "..."], examples: ['choose("Hello", "World", "!")'], }, + { + name: "map", + description: "Returns the value of the key of object, array or single value", + returnValue: "any", + arguments: ["object | array", "key"], + examples: ['map(user, "id")'], + }, + { + name: "find_i", + description: "Returns the index of the first argument in the array", + returnValue: "number", + arguments: ["array", "value"], + examples: ['find_i(["Hello", "World"], "World")'], + }, + { + name: "get_snowflake", + description: "Trims all non-numeric characters from a string", + returnValue: "string", + arguments: ["string"], + examples: ['get_snowflake("<@!344837487526412300>")'], + }, + { + name: "tag", + description: "Gets the value of another defined tag", + returnValue: "string", + arguments: ["tagName"], + examples: ['tag("tagName")'], + plugin: "tags", + }, + { + name: "get", + description: "Gets the value of a saved variable", + returnValue: "any", + arguments: ["variable"], + examples: ['get("variable")'], + plugin: "tags", + }, + { + name: "set", + description: "Sets the value of a saved variable", + returnValue: "none", + arguments: ["variableName", "value"], + examples: ['set("variableName", "value")'], + plugin: "tags", + }, + { + name: "setr", + description: "Sets the value of a saved variable and returns it", + returnValue: "any", + arguments: ["variableName", "value"], + examples: ['setr("variableName", "value")'], + plugin: "tags", + }, + { + name: "parseDateTime", + description: "Parses a date string/unix timestamp into a formated Date string", + returnValue: "string", + arguments: ["date"], + examples: ["parseDateTime(1643411583656)", 'parseDateTime("2020-01-01T00:00:00.000Z")'], + plugin: "tags", + }, + { + name: "countdown", + description: "Returns a countdown string to target timestamp", + returnValue: "string", + arguments: ["timestamp"], + examples: ["countdown(1577886400000)"], + plugin: "tags", + }, + { + name: "now", + description: "Returns the current timestamp", + returnValue: "number", + arguments: [], + examples: ["now()"], + plugin: "tags", + }, + { + name: "timeAdd", + description: "Adds a delay to a timestamp", + returnValue: "number", + arguments: ["timestamp", "delay"], + examples: ['timeAdd(1577886400000, "1h")', 'timeAdd("1h")'], + plugin: "tags", + }, + { + name: "timeSub", + description: "Subtracts a delay from a timestamp", + returnValue: "number", + arguments: ["timestamp", "delay"], + examples: ['timeSub(1577886400000, "1h")', 'timeSub("1h")'], + plugin: "tags", + }, + { + name: "timeAgo", + description: "Alias for timeSub", + returnValue: "number", + arguments: ["delay"], + examples: ['timeAgo("2h")'], + plugin: "tags", + }, + { + name: "formatTime", + description: "Formats a timestamp into a human readable string", + returnValue: "string", + arguments: ["timestamp", "formatStyle"], + examples: ['formatTime(now(), "YYYY-MM-DD HH")', 'formatTime(1577886400000, "YYYY-MM-DD")'], + plugin: "tags", + }, + { + name: "mention", + description: "Converts a snowflake to a mention", + returnValue: "string", + arguments: ["snowflake"], + examples: ["mention('344837487526412300')"], + plugin: "tags", + }, + { + name: "isMention", + description: "Checks if a string is a mention", + returnValue: "boolean", + arguments: ["string"], + examples: ['isMention("<@!344837487526412300>")'], + plugin: "tags", + }, + { + name: "get_user", + description: "Tries to resolve a user from ID or mention", + returnValue: 'ResolvedUser || ""', + arguments: ["string"], + examples: ['get_user("<@!344837487526412300>")', "get_user(get_snowflake(args.0))"], + plugin: "tags", + }, ]; diff --git a/backend/src/plugins/Tags/types.ts b/backend/src/plugins/Tags/types.ts index 3a7eb2b3..433ac09e 100644 --- a/backend/src/plugins/Tags/types.ts +++ b/backend/src/plugins/Tags/types.ts @@ -66,6 +66,7 @@ export interface TemplateFunction { returnValue: string; signature?: string; examples?: string[]; + plugin?: string; } export const tagsCmd = guildPluginMessageCommand();