Fix logAutomodAction error if Automod context doesn't include a user
This commit is contained in:
parent
204a8619ae
commit
3c8355babf
2 changed files with 5 additions and 5 deletions
|
@ -8,7 +8,7 @@ import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||||
|
|
||||||
interface LogAutomodActionData {
|
interface LogAutomodActionData {
|
||||||
rule: string;
|
rule: string;
|
||||||
user: User;
|
user?: User | null;
|
||||||
users: User[];
|
users: User[];
|
||||||
actionsTaken: string;
|
actionsTaken: string;
|
||||||
matchSummary: string;
|
matchSummary: string;
|
||||||
|
@ -20,14 +20,14 @@ export function logAutomodAction(pluginData: GuildPluginData<LogsPluginType>, da
|
||||||
LogType.AUTOMOD_ACTION,
|
LogType.AUTOMOD_ACTION,
|
||||||
createTypedTemplateSafeValueContainer({
|
createTypedTemplateSafeValueContainer({
|
||||||
rule: data.rule,
|
rule: data.rule,
|
||||||
user: userToTemplateSafeUser(data.user),
|
user: data.user ? userToTemplateSafeUser(data.user) : null,
|
||||||
users: data.users.map(user => userToTemplateSafeUser(user)),
|
users: data.users.map(user => userToTemplateSafeUser(user)),
|
||||||
actionsTaken: data.actionsTaken,
|
actionsTaken: data.actionsTaken,
|
||||||
matchSummary: data.matchSummary ?? "",
|
matchSummary: data.matchSummary ?? "",
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
userId: data.user.id,
|
userId: data.user ? data.user.id : null,
|
||||||
bot: data.user.bot,
|
bot: data.user ? data.user.bot : false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,7 +458,7 @@ export const LogTypeData = z.object({
|
||||||
|
|
||||||
[LogType.AUTOMOD_ACTION]: z.object({
|
[LogType.AUTOMOD_ACTION]: z.object({
|
||||||
rule: z.string(),
|
rule: z.string(),
|
||||||
user: z.instanceof(TemplateSafeUser),
|
user: z.instanceof(TemplateSafeUser).nullable(),
|
||||||
users: z.array(z.instanceof(TemplateSafeUser)),
|
users: z.array(z.instanceof(TemplateSafeUser)),
|
||||||
actionsTaken: z.string(),
|
actionsTaken: z.string(),
|
||||||
matchSummary: z.string(),
|
matchSummary: z.string(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue