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:
parent
fcfc96c30d
commit
723995f30c
2 changed files with 20 additions and 8 deletions
|
@ -7,6 +7,8 @@ import { automodTrigger } from "../helpers";
|
||||||
interface ThreadCreateResult {
|
interface ThreadCreateResult {
|
||||||
matchedThreadId: Snowflake;
|
matchedThreadId: Snowflake;
|
||||||
matchedThreadName: string;
|
matchedThreadName: string;
|
||||||
|
matchedThreadParentId: Snowflake;
|
||||||
|
matchedThreadParentName: string;
|
||||||
matchedThreadOwner: User | undefined;
|
matchedThreadOwner: User | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +35,8 @@ export const ThreadCreateTrigger = automodTrigger<ThreadCreateResult>()({
|
||||||
extra: {
|
extra: {
|
||||||
matchedThreadId: thread.id,
|
matchedThreadId: thread.id,
|
||||||
matchedThreadName: thread.name,
|
matchedThreadName: thread.name,
|
||||||
|
matchedThreadParentId: thread.parentId ?? "Unknown",
|
||||||
|
matchedThreadParentName: thread.parent?.name ?? "Unknown",
|
||||||
matchedThreadOwner: context.user,
|
matchedThreadOwner: context.user,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -42,11 +46,12 @@ export const ThreadCreateTrigger = automodTrigger<ThreadCreateResult>()({
|
||||||
const threadId = matchResult.extra.matchedThreadId;
|
const threadId = matchResult.extra.matchedThreadId;
|
||||||
const threadName = matchResult.extra.matchedThreadName;
|
const threadName = matchResult.extra.matchedThreadName;
|
||||||
const threadOwner = matchResult.extra.matchedThreadOwner;
|
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) {
|
if (threadOwner) {
|
||||||
return `Thread **#${Util.escapeBold(threadName)}** (\`${threadId}\`) has been created by **${
|
return `${base} by **${Util.escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
|
||||||
threadOwner.tag
|
|
||||||
}** (\`${threadOwner.id}\`)`;
|
|
||||||
}
|
}
|
||||||
return `Thread **#${Util.escapeBold(threadName)}** (\`${threadId}\`) has been created`;
|
return base;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,8 @@ import { automodTrigger } from "../helpers";
|
||||||
interface ThreadDeleteResult {
|
interface ThreadDeleteResult {
|
||||||
matchedThreadId: Snowflake;
|
matchedThreadId: Snowflake;
|
||||||
matchedThreadName: string;
|
matchedThreadName: string;
|
||||||
|
matchedThreadParentId: Snowflake;
|
||||||
|
matchedThreadParentName: string;
|
||||||
matchedThreadOwner: User | undefined;
|
matchedThreadOwner: User | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +35,8 @@ export const ThreadDeleteTrigger = automodTrigger<ThreadDeleteResult>()({
|
||||||
extra: {
|
extra: {
|
||||||
matchedThreadId: thread.id,
|
matchedThreadId: thread.id,
|
||||||
matchedThreadName: thread.name,
|
matchedThreadName: thread.name,
|
||||||
|
matchedThreadParentId: thread.parentId ?? "Unknown",
|
||||||
|
matchedThreadParentName: thread.parent?.name ?? "Unknown",
|
||||||
matchedThreadOwner: context.user,
|
matchedThreadOwner: context.user,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -40,13 +44,16 @@ export const ThreadDeleteTrigger = automodTrigger<ThreadDeleteResult>()({
|
||||||
|
|
||||||
renderMatchInformation({ matchResult }) {
|
renderMatchInformation({ matchResult }) {
|
||||||
const threadId = matchResult.extra.matchedThreadId;
|
const threadId = matchResult.extra.matchedThreadId;
|
||||||
const threadName = matchResult.extra.matchedThreadName;
|
|
||||||
const threadOwner = matchResult.extra.matchedThreadOwner;
|
const threadOwner = matchResult.extra.matchedThreadOwner;
|
||||||
|
const threadName = matchResult.extra.matchedThreadName;
|
||||||
|
const parentId = matchResult.extra.matchedThreadParentId;
|
||||||
|
const parentName = matchResult.extra.matchedThreadParentName;
|
||||||
if (threadOwner) {
|
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.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`;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue