mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
fix discord-api-types imports & usage of removed guild features (#335)
This commit is contained in:
parent
d60d2bc568
commit
7fb0d02adf
6 changed files with 17 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
|||
import { GuildFeature, ThreadAutoArchiveDuration } from "discord-api-types";
|
||||
import { GuildFeature, ThreadAutoArchiveDuration } from "discord-api-types/v9";
|
||||
import { TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter";
|
||||
|
@ -7,6 +7,13 @@ import { convertDelayStringToMS, MINUTES, noop, tDelayString, tNullable } from "
|
|||
import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { automodAction } from "../helpers";
|
||||
|
||||
const validThreadAutoArchiveDurations: ThreadAutoArchiveDuration[] = [
|
||||
ThreadAutoArchiveDuration.OneHour,
|
||||
ThreadAutoArchiveDuration.OneDay,
|
||||
ThreadAutoArchiveDuration.ThreeDays,
|
||||
ThreadAutoArchiveDuration.OneWeek,
|
||||
];
|
||||
|
||||
export const StartThreadAction = automodAction({
|
||||
configType: t.type({
|
||||
name: tNullable(t.string),
|
||||
|
@ -41,22 +48,9 @@ export const StartThreadAction = automodAction({
|
|||
const archiveSet = actionConfig.auto_archive
|
||||
? Math.ceil(Math.max(convertDelayStringToMS(actionConfig.auto_archive) ?? 0, 0) / MINUTES)
|
||||
: ThreadAutoArchiveDuration.OneDay;
|
||||
let autoArchive: ThreadAutoArchiveDuration;
|
||||
if (archiveSet === ThreadAutoArchiveDuration.OneDay) {
|
||||
autoArchive = ThreadAutoArchiveDuration.OneDay;
|
||||
} 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;
|
||||
}
|
||||
const autoArchive = validThreadAutoArchiveDurations.includes(archiveSet)
|
||||
? (archiveSet as ThreadAutoArchiveDuration)
|
||||
: ThreadAutoArchiveDuration.OneHour;
|
||||
|
||||
for (const threadContext of threads) {
|
||||
const channel = pluginData.guild.channels.cache.get(threadContext.message!.channel_id) as TextChannel;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake } from "discord-api-types";
|
||||
import { Snowflake } from "discord-api-types/v9";
|
||||
import { User, Util } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { tNullable } from "../../../utils";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake } from "discord-api-types";
|
||||
import { Snowflake } from "discord-api-types/v9";
|
||||
import { User, Util } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake } from "discord-api-types";
|
||||
import { Snowflake } from "discord-api-types/v9";
|
||||
import { User, Util } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake } from "discord-api-types";
|
||||
import { Snowflake } from "discord-api-types/v9";
|
||||
import { User, Util } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { tNullable } from "../../../utils";
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { GuildTextBasedChannel, Message, MessageOptions, NewsChannel, TextChannel, WebhookClient } from "discord.js";
|
||||
import { GuildTextBasedChannel, MessageOptions, WebhookClient } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { InternalPosterPluginType } from "../types";
|
||||
import { channelIsWebhookable, getOrCreateWebhookForChannel } from "./getOrCreateWebhookForChannel";
|
||||
import { APIMessage } from "discord-api-types";
|
||||
import { channelIsWebhookable } from "./getOrCreateWebhookForChannel";
|
||||
import { isDiscordAPIError } from "../../../utils";
|
||||
import { getOrCreateWebhookClientForChannel } from "./getOrCreateWebhookClientForChannel";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue