3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 01:25:02 +00:00

shorten the line!

This commit is contained in:
metal 2021-09-06 16:43:19 +00:00 committed by GitHub
parent 39fc748982
commit ac8284ade0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,9 +3,8 @@ import { TextChannel } from "discord.js";
import * as t from "io-ts";
import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter";
import { ChannelTypeStrings } from "src/types";
import { convertDelayStringToMS, MINUTES, tDelayString, tNullable } from "../../../utils";
import { convertDelayStringToMS, MINUTES, tDelayString, tNullable, noop } from "../../../utils";
import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { noop } from "../../../utils";
import { automodAction } from "../helpers";
export const StartThreadAction = automodAction({
@ -29,14 +28,9 @@ export const StartThreadAction = automodAction({
if (channel?.type !== ChannelTypeStrings.TEXT || !channel.isText()) return false; // for some reason the typing here for channel.type defaults to ThreadChannelTypes (?)
// check against max threads per channel
if (actionConfig.limit_per_channel && actionConfig.limit_per_channel > 0) {
const threadCount = [
...channel.threads.cache
.filter(
tr =>
tr.ownerId === pluginData.client.user!.id && !tr.deleted && !tr.archived && tr.parentId === channel.id,
)
.keys(),
].length; // very short line, yes yes
const threadCount = channel.threads.cache.filter(
tr => tr.ownerId === pluginData.client.user!.id && !tr.deleted && !tr.archived && tr.parentId === channel.id,
).size;
if (threadCount >= actionConfig.limit_per_channel) return false;
}
return channel.messages.cache.has(c.message.id);