Merge remote-tracking branch 'origin/master' into 220601_docker_wip

This commit is contained in:
Dragory 2022-06-26 14:38:36 +03:00
commit 177a66a247
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
7 changed files with 18 additions and 25 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 * 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;

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 * as t from "io-ts";
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 * as t from "io-ts";
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 * as t from "io-ts";
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 * as t from "io-ts";
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 { 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";

View file

@ -20,7 +20,7 @@ const MAX_ROLES_TO_DISPLAY = 15;
const trimRoles = (roles: string[]) =>
roles.length > MAX_ROLES_TO_DISPLAY
? roles.slice(0, MAX_ROLES_TO_DISPLAY).join(", ") + `, and ${MAX_ROLES_TO_DISPLAY - roles.length} more roles`
? roles.slice(0, MAX_ROLES_TO_DISPLAY).join(", ") + `, and ${roles.length - MAX_ROLES_TO_DISPLAY} more roles`
: roles.join(", ");
export async function getUserInfoEmbed(