From bf8900b6a5e3a156f95db64e184447aa48ac0c3c Mon Sep 17 00:00:00 2001 From: Tiago R Date: Mon, 9 Oct 2023 09:46:26 +0000 Subject: [PATCH] get_user Signed-off-by: GitHub --- backend/src/plugins/Tags/util/renderTagBody.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Tags/util/renderTagBody.ts b/backend/src/plugins/Tags/util/renderTagBody.ts index e75a12cf..e2b8b403 100644 --- a/backend/src/plugins/Tags/util/renderTagBody.ts +++ b/backend/src/plugins/Tags/util/renderTagBody.ts @@ -1,6 +1,7 @@ import { ExtendedMatchParams, GuildPluginData } from "knub"; import { TemplateSafeValue, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; -import { StrictMessageContent, renderRecursively } from "../../../utils"; +import { StrictMessageContent, UnknownUser, renderRecursively, resolveUser } from "../../../utils"; +import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js"; import { TTag, TagsPluginType } from "../types"; import { findTagByName } from "./findTagByName"; @@ -39,6 +40,12 @@ export async function renderTagBody( if (emptyObject[name]) return; return !Object.hasOwn(dynamicVars, name) || dynamicVars[name] == null ? "" : dynamicVars[name]; }, + async get_user(str) { + if (!str || typeof str !== "string") return ""; + const resolved = await resolveUser(pluginData.client, str); + if (resolved instanceof UnknownUser) return ""; + return userToTemplateSafeUser(resolved); + }, tag: async (name, ...subTagArgs) => { if (++tagFnCallsObj.calls > MAX_TAG_FN_CALLS) return ""; if (typeof name !== "string") return "";