3
0
Fork 0
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:
Almeida 2022-06-26 12:09:27 +01:00 committed by GitHub
parent d60d2bc568
commit 7fb0d02adf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 24 deletions

View file

@ -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 { TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter"; import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter";
@ -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;

View file

@ -1,4 +1,4 @@
import { Snowflake } from "discord-api-types"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { User, Util } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { tNullable } from "../../../utils"; import { tNullable } from "../../../utils";

View file

@ -1,4 +1,4 @@
import { Snowflake } from "discord-api-types"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { User, Util } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";

View file

@ -1,4 +1,4 @@
import { Snowflake } from "discord-api-types"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { User, Util } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";

View file

@ -1,4 +1,4 @@
import { Snowflake } from "discord-api-types"; import { Snowflake } from "discord-api-types/v9";
import { User, Util } from "discord.js"; import { User, Util } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { tNullable } from "../../../utils"; import { tNullable } from "../../../utils";

View file

@ -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 { GuildPluginData } from "knub";
import { InternalPosterPluginType } from "../types"; import { InternalPosterPluginType } from "../types";
import { channelIsWebhookable, getOrCreateWebhookForChannel } from "./getOrCreateWebhookForChannel"; import { channelIsWebhookable } from "./getOrCreateWebhookForChannel";
import { APIMessage } from "discord-api-types";
import { isDiscordAPIError } from "../../../utils"; import { isDiscordAPIError } from "../../../utils";
import { getOrCreateWebhookClientForChannel } from "./getOrCreateWebhookClientForChannel"; import { getOrCreateWebhookClientForChannel } from "./getOrCreateWebhookClientForChannel";