mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 02:57:20 +00:00
get_user
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
c0f3ac11f0
commit
bf8900b6a5
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { ExtendedMatchParams, GuildPluginData } from "knub";
|
import { ExtendedMatchParams, GuildPluginData } from "knub";
|
||||||
import { TemplateSafeValue, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter";
|
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 { TTag, TagsPluginType } from "../types";
|
||||||
import { findTagByName } from "./findTagByName";
|
import { findTagByName } from "./findTagByName";
|
||||||
|
|
||||||
|
@ -39,6 +40,12 @@ export async function renderTagBody(
|
||||||
if (emptyObject[name]) return;
|
if (emptyObject[name]) return;
|
||||||
return !Object.hasOwn(dynamicVars, name) || dynamicVars[name] == null ? "" : dynamicVars[name];
|
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) => {
|
tag: async (name, ...subTagArgs) => {
|
||||||
if (++tagFnCallsObj.calls > MAX_TAG_FN_CALLS) return "";
|
if (++tagFnCallsObj.calls > MAX_TAG_FN_CALLS) return "";
|
||||||
if (typeof name !== "string") return "";
|
if (typeof name !== "string") return "";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue