More rework progress, remove all eris imports
This commit is contained in:
parent
8f7a6510eb
commit
52839cc9f3
181 changed files with 352 additions and 343 deletions
|
@ -2,7 +2,8 @@ import * as t from "io-ts";
|
|||
import { automodAction } from "../helpers";
|
||||
import { convertDelayStringToMS, isDiscordRESTError, tDelayString, tNullable } from "../../../utils";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { Constants, TextChannel } from "eris";
|
||||
import { Constants, TextChannel } from "discord.js";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
|
||||
export const SetSlowmodeAction = automodAction({
|
||||
configType: t.type({
|
||||
|
@ -18,24 +19,22 @@ export const SetSlowmodeAction = automodAction({
|
|||
const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0);
|
||||
|
||||
for (const channelId of actionConfig.channels) {
|
||||
const channel = pluginData.guild.channels.get(channelId);
|
||||
const channel = pluginData.guild.channels.cache.get(channelId);
|
||||
|
||||
// Only text channels and text channels within categories support slowmodes
|
||||
if (
|
||||
!channel ||
|
||||
!(channel.type === Constants.ChannelTypes.GUILD_TEXT || channel.type === Constants.ChannelTypes.GUILD_CATEGORY)
|
||||
) {
|
||||
if (!channel || !(channel.type === ChannelTypeStrings.TEXT || ChannelTypeStrings.CATEGORY)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let channelsToSlowmode: TextChannel[] = [];
|
||||
if (channel.type === Constants.ChannelTypes.GUILD_CATEGORY) {
|
||||
if (channel.type === ChannelTypeStrings.CATEGORY) {
|
||||
// Find all text channels within the category
|
||||
channelsToSlowmode = pluginData.guild.channels.filter(
|
||||
ch => ch.parentID === channel.id && ch.type === Constants.ChannelTypes.GUILD_TEXT,
|
||||
) as TextChannel[];
|
||||
for (const ch of pluginData.guild.channels.cache.values()) {
|
||||
if (ch.parentID === channel.id && ch.type === ChannelTypeStrings.TEXT)
|
||||
channelsToSlowmode.push(ch as TextChannel);
|
||||
}
|
||||
} else {
|
||||
channelsToSlowmode.push(channel);
|
||||
channelsToSlowmode.push(channel as TextChannel);
|
||||
}
|
||||
|
||||
const slowmodeSeconds = Math.ceil(slowmodeMs / 1000);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue