mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-16 06:35:03 +00:00
Merge master
This commit is contained in:
commit
1518d58e25
53 changed files with 289 additions and 320 deletions
|
@ -1,6 +1,5 @@
|
|||
import {
|
||||
ChannelType,
|
||||
GuildFeature,
|
||||
GuildTextThreadCreateOptions,
|
||||
ThreadAutoArchiveDuration,
|
||||
ThreadChannel,
|
||||
|
@ -43,7 +42,6 @@ export const StartThreadAction = automodAction({
|
|||
return true;
|
||||
});
|
||||
|
||||
const guild = pluginData.guild;
|
||||
const archiveSet = actionConfig.auto_archive
|
||||
? Math.ceil(Math.max(convertDelayStringToMS(actionConfig.auto_archive) ?? 0, 0) / MINUTES)
|
||||
: ThreadAutoArchiveDuration.OneDay;
|
||||
|
@ -53,7 +51,7 @@ export const StartThreadAction = automodAction({
|
|||
|
||||
for (const threadContext of threads) {
|
||||
const channel = pluginData.guild.channels.cache.get(threadContext.message!.channel_id);
|
||||
if (!channel || !("threads" in channel) || channel.type === ChannelType.GuildForum) continue;
|
||||
if (!channel || !("threads" in channel) || channel.isThreadOnly()) continue;
|
||||
|
||||
const renderThreadName = async (str: string) =>
|
||||
renderTemplate(
|
||||
|
@ -67,10 +65,7 @@ export const StartThreadAction = automodAction({
|
|||
const threadOptions: GuildTextThreadCreateOptions<unknown> = {
|
||||
name: threadName,
|
||||
autoArchiveDuration: autoArchive,
|
||||
startMessage:
|
||||
!actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads)
|
||||
? threadContext.message!.id
|
||||
: undefined,
|
||||
startMessage: !actionConfig.private ? threadContext.message!.id : undefined,
|
||||
};
|
||||
|
||||
let thread: ThreadChannel | undefined;
|
||||
|
@ -86,10 +81,7 @@ export const StartThreadAction = automodAction({
|
|||
.create({
|
||||
...threadOptions,
|
||||
type: actionConfig.private ? ChannelType.PrivateThread : ChannelType.PublicThread,
|
||||
startMessage:
|
||||
!actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads)
|
||||
? threadContext.message!.id
|
||||
: undefined,
|
||||
startMessage: !actionConfig.private ? threadContext.message!.id : undefined,
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ export async function* matchMultipleTextTypesOnMessage(
|
|||
}
|
||||
|
||||
if (trigger.match_visible_names) {
|
||||
yield ["visiblename", member.nickname || msg.data.author.username];
|
||||
yield ["visiblename", member.displayName || msg.data.author.username];
|
||||
}
|
||||
|
||||
if (trigger.match_usernames) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import z from "zod";
|
||||
import { renderUserUsername, zSnowflake } from "../../../utils";
|
||||
import { zSnowflake } from "../../../utils";
|
||||
import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
|
@ -38,7 +38,7 @@ export const RoleAddedTrigger = automodTrigger<RoleAddedMatchResult>()({
|
|||
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
|
||||
const roleName = role?.name || "Unknown";
|
||||
const member = contexts[0].member!;
|
||||
const memberName = `**${renderUserUsername(member.user)}** (\`${member.id}\`)`;
|
||||
const memberName = `**${renderUsername(member)}** (\`${member.id}\`)`;
|
||||
return `Role ${roleName} (\`${matchResult.extra.matchedRoleId}\`) was added to ${memberName}`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import z from "zod";
|
||||
import { renderUserUsername, zSnowflake } from "../../../utils";
|
||||
import { zSnowflake } from "../../../utils";
|
||||
import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
|
@ -38,7 +38,7 @@ export const RoleRemovedTrigger = automodTrigger<RoleAddedMatchResult>()({
|
|||
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
|
||||
const roleName = role?.name || "Unknown";
|
||||
const member = contexts[0].member!;
|
||||
const memberName = `**${renderUserUsername(member.user)}** (\`${member.id}\`)`;
|
||||
const memberName = `**${renderUsername(member)}** (\`${member.id}\`)`;
|
||||
return `Role ${roleName} (\`${matchResult.extra.matchedRoleId}\`) was removed from ${memberName}`;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { User, escapeBold, type Snowflake } from "discord.js";
|
||||
import z from "zod";
|
||||
import { renderUsername } from "../../../utils";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
interface ThreadArchiveResult {
|
||||
|
@ -47,7 +48,7 @@ export const ThreadArchiveTrigger = automodTrigger<ThreadArchiveResult>()({
|
|||
const parentName = matchResult.extra.matchedThreadParentName;
|
||||
const base = `Thread **#${threadName}** (\`${threadId}\`) has been archived in the **#${parentName}** (\`${parentId}\`) channel`;
|
||||
if (threadOwner) {
|
||||
return `${base} by **${escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
|
||||
return `${base} by **${escapeBold(renderUsername(threadOwner))}** (\`${threadOwner.id}\`)`;
|
||||
}
|
||||
return base;
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { User, escapeBold, type Snowflake } from "discord.js";
|
||||
import z from "zod";
|
||||
import { renderUsername } from "../../../utils.js";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
interface ThreadCreateResult {
|
||||
|
@ -41,7 +42,7 @@ export const ThreadCreateTrigger = automodTrigger<ThreadCreateResult>()({
|
|||
const parentName = matchResult.extra.matchedThreadParentName;
|
||||
const base = `Thread **#${threadName}** (\`${threadId}\`) has been created in the **#${parentName}** (\`${parentId}\`) channel`;
|
||||
if (threadOwner) {
|
||||
return `${base} by **${escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
|
||||
return `${base} by **${escapeBold(renderUsername(threadOwner))}** (\`${threadOwner.id}\`)`;
|
||||
}
|
||||
return base;
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { User, escapeBold, type Snowflake } from "discord.js";
|
||||
import z from "zod";
|
||||
import { renderUsername } from "../../../utils.js";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
interface ThreadDeleteResult {
|
||||
|
@ -41,7 +42,7 @@ export const ThreadDeleteTrigger = automodTrigger<ThreadDeleteResult>()({
|
|||
const parentName = matchResult.extra.matchedThreadParentName;
|
||||
if (threadOwner) {
|
||||
return `Thread **#${threadName ?? "Unknown"}** (\`${threadId}\`) created by **${escapeBold(
|
||||
threadOwner.tag,
|
||||
renderUsername(threadOwner),
|
||||
)}** (\`${threadOwner.id}\`) in the **#${parentName}** (\`${parentId}\`) channel has been deleted`;
|
||||
}
|
||||
return `Thread **#${
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { User, escapeBold, type Snowflake } from "discord.js";
|
||||
import z from "zod";
|
||||
import { renderUsername } from "../../../utils";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
interface ThreadUnarchiveResult {
|
||||
|
@ -47,7 +48,7 @@ export const ThreadUnarchiveTrigger = automodTrigger<ThreadUnarchiveResult>()({
|
|||
const parentName = matchResult.extra.matchedThreadParentName;
|
||||
const base = `Thread **#${threadName}** (\`${threadId}\`) has been unarchived in the **#${parentName}** (\`${parentId}\`) channel`;
|
||||
if (threadOwner) {
|
||||
return `${base} by **${escapeBold(threadOwner.tag)}** (\`${threadOwner.id}\`)`;
|
||||
return `${base} by **${escapeBold(renderUsername(threadOwner))}** (\`${threadOwner.id}\`)`;
|
||||
}
|
||||
return base;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue