mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 01:25:02 +00:00
check guild features & add msg to templates
This commit is contained in:
parent
c8a68d8342
commit
a36ef9c22e
1 changed files with 13 additions and 6 deletions
|
@ -1,9 +1,9 @@
|
||||||
import { ThreadAutoArchiveDuration } from "discord-api-types";
|
import { GuildFeature, ThreadAutoArchiveDuration } from "discord-api-types";
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { renderTemplate, TemplateSafeValueContainer } from "src/templateFormatter";
|
import { renderTemplate, TemplateSafeValueContainer } from "src/templateFormatter";
|
||||||
import { convertDelayStringToMS, tDelayString, tNullable } from "src/utils";
|
import { convertDelayStringToMS, tDelayString, tNullable } from "src/utils";
|
||||||
import { userToTemplateSafeUser } from "src/utils/templateSafeObjects";
|
import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "src/utils/templateSafeObjects";
|
||||||
import { noop } from "../../../utils";
|
import { noop } from "../../../utils";
|
||||||
import { automodAction } from "../helpers";
|
import { automodAction } from "../helpers";
|
||||||
|
|
||||||
|
@ -39,12 +39,14 @@ export const StartThreadAction = automodAction({
|
||||||
}
|
}
|
||||||
return channel.messages.cache.has(c.message.id);
|
return channel.messages.cache.has(c.message.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const guild = await pluginData.guild;
|
||||||
let autoArchive: ThreadAutoArchiveDuration;
|
let autoArchive: ThreadAutoArchiveDuration;
|
||||||
if (actionConfig.auto_archive === 1440) {
|
if (actionConfig.auto_archive === 1440) {
|
||||||
autoArchive = ThreadAutoArchiveDuration.OneDay;
|
autoArchive = ThreadAutoArchiveDuration.OneDay;
|
||||||
} else if (actionConfig.auto_archive === 4320) {
|
} else if (actionConfig.auto_archive === 4320 && guild.features.includes(GuildFeature.ThreeDayThreadArchive)) {
|
||||||
autoArchive = ThreadAutoArchiveDuration.ThreeDays;
|
autoArchive = ThreadAutoArchiveDuration.ThreeDays;
|
||||||
} else if (actionConfig.auto_archive === 10080) {
|
} else if (actionConfig.auto_archive === 10080 && guild.features.includes(GuildFeature.SevenDayThreadArchive)) {
|
||||||
autoArchive = ThreadAutoArchiveDuration.OneWeek;
|
autoArchive = ThreadAutoArchiveDuration.OneWeek;
|
||||||
} else {
|
} else {
|
||||||
autoArchive = ThreadAutoArchiveDuration.OneHour;
|
autoArchive = ThreadAutoArchiveDuration.OneHour;
|
||||||
|
@ -57,6 +59,7 @@ export const StartThreadAction = automodAction({
|
||||||
str,
|
str,
|
||||||
new TemplateSafeValueContainer({
|
new TemplateSafeValueContainer({
|
||||||
user: userToTemplateSafeUser(c.user!),
|
user: userToTemplateSafeUser(c.user!),
|
||||||
|
msg: savedMessageToTemplateSafeSavedMessage(c.message!),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const threadName = await renderThreadName(actionConfig.name ?? "{user.username}#{user.discriminator}s thread");
|
const threadName = await renderThreadName(actionConfig.name ?? "{user.username}#{user.discriminator}s thread");
|
||||||
|
@ -64,8 +67,12 @@ export const StartThreadAction = automodAction({
|
||||||
.create({
|
.create({
|
||||||
name: threadName,
|
name: threadName,
|
||||||
autoArchiveDuration: autoArchive,
|
autoArchiveDuration: autoArchive,
|
||||||
type: actionConfig.private ? "GUILD_PRIVATE_THREAD" : "GUILD_PUBLIC_THREAD",
|
type:
|
||||||
startMessage: !actionConfig.private ? c.message!.id : undefined,
|
actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads)
|
||||||
|
? "GUILD_PRIVATE_THREAD"
|
||||||
|
: "GUILD_PUBLIC_THREAD",
|
||||||
|
startMessage:
|
||||||
|
!actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads) ? c.message!.id : undefined,
|
||||||
})
|
})
|
||||||
.catch(noop);
|
.catch(noop);
|
||||||
if (actionConfig.slowmode && thread) {
|
if (actionConfig.slowmode && thread) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue