3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-07 02:57:20 +00:00
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Tiago R 2023-10-09 09:46:26 +00:00 committed by GitHub
parent c0f3ac11f0
commit bf8900b6a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 "";