3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-11 04:57:19 +00:00

added parent info in the matchSummary

This commit is contained in:
almeidx 2021-08-29 15:30:36 +01:00
parent fcfc96c30d
commit 723995f30c
No known key found for this signature in database
GPG key ID: 01C5E03866747F46
2 changed files with 20 additions and 8 deletions

View file

@ -7,6 +7,8 @@ import { automodTrigger } from "../helpers";
interface ThreadCreateResult {
matchedThreadId: Snowflake;
matchedThreadName: string;
matchedThreadParentId: Snowflake;
matchedThreadParentName: string;
matchedThreadOwner: User | undefined;
}
@ -33,6 +35,8 @@ export const ThreadCreateTrigger = automodTrigger<ThreadCreateResult>()({
extra: {
matchedThreadId: thread.id,
matchedThreadName: thread.name,
matchedThreadParentId: thread.parentId ?? "Unknown",
matchedThreadParentName: thread.parent?.name ?? "Unknown",
matchedThreadOwner: context.user,
},
};
@ -42,11 +46,12 @@ export const ThreadCreateTrigger = automodTrigger<ThreadCreateResult>()({
const threadId = matchResult.extra.matchedThreadId;
const threadName = matchResult.extra.matchedThreadName;
const threadOwner = matchResult.extra.matchedThreadOwner;
const parentId = matchResult.extra.matchedThreadParentId;
const parentName = matchResult.extra.matchedThreadParentName;
const base = `Thread **#${threadName}** (\`${threadId}\`) has been created in the **#${parentName}** (\`${parentId}\`) channel`;
if (threadOwner) {
return `Thread **#${Util.escapeBold(threadName)}** (\`${threadId}\`) has been created by **${
threadOwner.tag
}** (\`${threadOwner.id}\`)`;
return `${base} by **${Util.escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
}
return `Thread **#${Util.escapeBold(threadName)}** (\`${threadId}\`) has been created`;
return base;
},
});

View file

@ -7,6 +7,8 @@ import { automodTrigger } from "../helpers";
interface ThreadDeleteResult {
matchedThreadId: Snowflake;
matchedThreadName: string;
matchedThreadParentId: Snowflake;
matchedThreadParentName: string;
matchedThreadOwner: User | undefined;
}
@ -33,6 +35,8 @@ export const ThreadDeleteTrigger = automodTrigger<ThreadDeleteResult>()({
extra: {
matchedThreadId: thread.id,
matchedThreadName: thread.name,
matchedThreadParentId: thread.parentId ?? "Unknown",
matchedThreadParentName: thread.parent?.name ?? "Unknown",
matchedThreadOwner: context.user,
},
};
@ -40,13 +44,16 @@ export const ThreadDeleteTrigger = automodTrigger<ThreadDeleteResult>()({
renderMatchInformation({ matchResult }) {
const threadId = matchResult.extra.matchedThreadId;
const threadName = matchResult.extra.matchedThreadName;
const threadOwner = matchResult.extra.matchedThreadOwner;
const threadName = matchResult.extra.matchedThreadName;
const parentId = matchResult.extra.matchedThreadParentId;
const parentName = matchResult.extra.matchedThreadParentName;
if (threadOwner) {
return `Thread **${Util.escapeBold(threadName ?? "Unknown")}** (\`${threadId}\`) created by **${Util.escapeBold(
return `Thread **#${threadName ?? "Unknown"}** (\`${threadId}\`) created by **${Util.escapeBold(
threadOwner.tag,
)}** (\`${threadOwner.id}\`) has been deleted`;
)}** (\`${threadOwner.id}\`) in the **#${parentName}** (\`${parentId}\`) channel has been deleted`;
}
return `Thread **${Util.escapeBold(threadName ?? "Unknown")}** (\`${threadId}\`) has been deleted`;
return `Thread **#${threadName ??
"Unknown"}** (\`${threadId}\`) from the **#${parentName}** (\`${parentId}\`) channel has been deleted`;
},
});