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

half the number of errors

This commit is contained in:
almeidx 2023-03-11 19:31:36 +00:00
parent 7c5e6eb91f
commit 1dca8c4447
No known key found for this signature in database
GPG key ID: B1F4887CEBE2EDB1
261 changed files with 760 additions and 1023 deletions

View file

@ -1,4 +1,3 @@
import { TextChannel } from "discord.js";
import humanizeDuration from "humanize-duration";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { slowmodeCmd } from "../types";
@ -13,7 +12,7 @@ export const SlowmodeGetCmd = slowmodeCmd({
},
async run({ message: msg, args, pluginData }) {
const channel = args.channel || (msg.channel as TextChannel);
const channel = args.channel || msg.channel;
let currentSlowmode = channel.rateLimitPerUser;
let isNative = true;

View file

@ -1,11 +1,4 @@
import {
ChannelType,
escapeInlineCode,
GuildTextBasedChannel,
PermissionsBitField,
TextChannel,
ThreadChannel,
} from "discord.js";
import { escapeInlineCode, PermissionsBitField } from "discord.js";
import humanizeDuration from "humanize-duration";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
@ -29,7 +22,6 @@ export const SlowmodeSetCmd = slowmodeCmd({
permission: "can_manage",
source: "guild",
// prettier-ignore
signature: [
{
time: ct.delay(),
@ -41,11 +33,16 @@ export const SlowmodeSetCmd = slowmodeCmd({
time: ct.delay(),
mode: ct.string({ option: true, shortcut: "m" }),
}
},
],
async run({ message: msg, args, pluginData }) {
const channel: GuildTextBasedChannel = args.channel || msg.channel;
const channel = args.channel || msg.channel;
if (!channel.isTextBased() || channel.isThread()) {
sendErrorMessage(pluginData, msg.channel, "Slowmode can only be set on non-thread text-based channels");
return;
}
if (args.time === 0) {
// Workaround until we can call SlowmodeDisableCmd from here
@ -135,9 +132,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
// Set native slowmode
try {
await channel.edit({
rateLimitPerUser: rateLimitSeconds,
});
await channel.setRateLimitPerUser(rateLimitSeconds);
} catch (e) {
sendErrorMessage(pluginData, msg.channel, `Failed to set native slowmode: ${escapeInlineCode(e.message)}`);
return;
@ -145,9 +140,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
} else {
// If there is an existing native slowmode, disable that first
if (channel.rateLimitPerUser) {
await channel.edit({
rateLimitPerUser: 0,
});
await channel.setRateLimitPerUser(0);
}
// Set bot-maintained slowmode
@ -155,7 +148,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
// Update cache
const slowmode = await pluginData.state.slowmodes.getChannelSlowmode(channel.id);
await pluginData.state.channelSlowmodeCache.set(channel.id, slowmode ?? null);
pluginData.state.channelSlowmodeCache.set(channel.id, slowmode ?? null);
}
const humanizedSlowmodeTime = humanizeDuration(args.time);