3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

tags: fix missing member/user variables

This commit is contained in:
Dragory 2020-09-15 17:22:29 +03:00
parent 33d75af1fc
commit 6923d12aa7
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 21 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import { MessageContent } from "eris";
import { TemplateParseError } from "../../../templateFormatter";
import { sendErrorMessage } from "../../../pluginUtils";
import { renderTagBody } from "../util/renderTagBody";
import { stripObjectToScalars } from "../../../utils";
export const TagEvalCmd = tagsCmd({
trigger: "tag eval",
@ -15,7 +16,16 @@ export const TagEvalCmd = tagsCmd({
async run({ message: msg, args, pluginData }) {
try {
const rendered = await renderTagBody(pluginData, args.body, [], {}, { member: msg.member });
const rendered = await renderTagBody(
pluginData,
args.body,
[],
{
member: stripObjectToScalars(msg.member, ["user"]),
user: stripObjectToScalars(msg.member.user),
},
{ member: msg.member },
);
msg.channel.createMessage(rendered);
} catch (e) {
if (e instanceof TemplateParseError) {

View file

@ -23,7 +23,16 @@ export async function renderTagFromString(
// Format the string
try {
return renderTagBody(pluginData, tagBody, tagArgs, {}, { member });
return renderTagBody(
pluginData,
tagBody,
tagArgs,
{
member: stripObjectToScalars(member, ["user"]),
user: stripObjectToScalars(member.user),
},
{ member },
);
} catch (e) {
if (e instanceof TemplateParseError) {
const logs = pluginData.getPlugin(LogsPlugin);