mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 11:07:19 +00:00
initial
This commit is contained in:
parent
047ab872df
commit
2907f5c079
1 changed files with 8 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { ChannelType, GuildTextBasedChannel, Snowflake } from "discord.js";
|
import { ChannelType, GuildTextBasedChannel, Snowflake, TextChannel, ThreadChannel } from "discord.js";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { convertDelayStringToMS, isDiscordAPIError, tDelayString, tNullable } from "../../../utils";
|
import { convertDelayStringToMS, isDiscordAPIError, tDelayString, tNullable } from "../../../utils";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
|
@ -6,7 +6,7 @@ import { automodAction } from "../helpers";
|
||||||
|
|
||||||
export const SetSlowmodeAction = automodAction({
|
export const SetSlowmodeAction = automodAction({
|
||||||
configType: t.type({
|
configType: t.type({
|
||||||
channels: t.array(t.string),
|
channels: tNullable(t.array(t.string)),
|
||||||
duration: tNullable(tDelayString),
|
duration: tNullable(tDelayString),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -14,10 +14,13 @@ export const SetSlowmodeAction = automodAction({
|
||||||
duration: "10s",
|
duration: "10s",
|
||||||
},
|
},
|
||||||
|
|
||||||
async apply({ pluginData, actionConfig }) {
|
async apply({ pluginData, actionConfig, contexts }) {
|
||||||
const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0);
|
const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0);
|
||||||
|
const channels = actionConfig.channels ?? new Array();
|
||||||
for (const channelId of actionConfig.channels) {
|
if (channels.length === 0) {
|
||||||
|
channels.push(...contexts.filter(c => c.message?.channel_id).map(c => c.message!.channel_id));
|
||||||
|
}
|
||||||
|
for (const channelId of channels) {
|
||||||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
||||||
|
|
||||||
// Only text channels and text channels within categories support slowmodes
|
// Only text channels and text channels within categories support slowmodes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue