mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 10:25:01 +00:00
fix startThread
This commit is contained in:
parent
6109af80cc
commit
7da620e529
1 changed files with 10 additions and 16 deletions
|
@ -7,6 +7,13 @@ import { convertDelayStringToMS, MINUTES, noop, tDelayString, tNullable } from "
|
||||||
import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||||
import { automodAction } from "../helpers";
|
import { automodAction } from "../helpers";
|
||||||
|
|
||||||
|
const validThreadAutoArchiveDurations: ThreadAutoArchiveDuration[] = [
|
||||||
|
ThreadAutoArchiveDuration.OneHour,
|
||||||
|
ThreadAutoArchiveDuration.OneDay,
|
||||||
|
ThreadAutoArchiveDuration.ThreeDays,
|
||||||
|
ThreadAutoArchiveDuration.OneWeek,
|
||||||
|
];
|
||||||
|
|
||||||
export const StartThreadAction = automodAction({
|
export const StartThreadAction = automodAction({
|
||||||
configType: t.type({
|
configType: t.type({
|
||||||
name: tNullable(t.string),
|
name: tNullable(t.string),
|
||||||
|
@ -41,22 +48,9 @@ export const StartThreadAction = automodAction({
|
||||||
const archiveSet = actionConfig.auto_archive
|
const archiveSet = actionConfig.auto_archive
|
||||||
? Math.ceil(Math.max(convertDelayStringToMS(actionConfig.auto_archive) ?? 0, 0) / MINUTES)
|
? Math.ceil(Math.max(convertDelayStringToMS(actionConfig.auto_archive) ?? 0, 0) / MINUTES)
|
||||||
: ThreadAutoArchiveDuration.OneDay;
|
: ThreadAutoArchiveDuration.OneDay;
|
||||||
let autoArchive: ThreadAutoArchiveDuration;
|
const autoArchive = validThreadAutoArchiveDurations.includes(archiveSet)
|
||||||
if (archiveSet === ThreadAutoArchiveDuration.OneDay) {
|
? (archiveSet as ThreadAutoArchiveDuration)
|
||||||
autoArchive = ThreadAutoArchiveDuration.OneDay;
|
: ThreadAutoArchiveDuration.OneHour;
|
||||||
} else if (
|
|
||||||
archiveSet === ThreadAutoArchiveDuration.ThreeDays &&
|
|
||||||
guild.features.includes(GuildFeature.ThreeDayThreadArchive)
|
|
||||||
) {
|
|
||||||
autoArchive = ThreadAutoArchiveDuration.ThreeDays;
|
|
||||||
} else if (
|
|
||||||
archiveSet === ThreadAutoArchiveDuration.OneWeek &&
|
|
||||||
guild.features.includes(GuildFeature.SevenDayThreadArchive)
|
|
||||||
) {
|
|
||||||
autoArchive = ThreadAutoArchiveDuration.OneWeek;
|
|
||||||
} else {
|
|
||||||
autoArchive = ThreadAutoArchiveDuration.OneHour;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const threadContext of threads) {
|
for (const threadContext of threads) {
|
||||||
const channel = pluginData.guild.channels.cache.get(threadContext.message!.channel_id) as TextChannel;
|
const channel = pluginData.guild.channels.cache.get(threadContext.message!.channel_id) as TextChannel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue