mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-13 21:35:02 +00:00
Finish preliminary rework, ready to test
This commit is contained in:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
backend/src/plugins/Slowmode/commands
|
@ -2,6 +2,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|||
import { slowmodeCmd } from "../types";
|
||||
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { TextChannel } from "discord.js";
|
||||
|
||||
export const SlowmodeGetCmd = slowmodeCmd({
|
||||
trigger: "slowmode",
|
||||
|
@ -29,9 +30,9 @@ export const SlowmodeGetCmd = slowmodeCmd({
|
|||
if (currentSlowmode) {
|
||||
const humanized = humanizeDuration(channel.rateLimitPerUser * 1000);
|
||||
const slowmodeType = isNative ? "native" : "bot-maintained";
|
||||
msg.channel.createMessage(`The current slowmode of <#${channel.id}> is **${humanized}** (${slowmodeType})`);
|
||||
msg.channel.send(`The current slowmode of <#${channel.id}> is **${humanized}** (${slowmodeType})`);
|
||||
} else {
|
||||
msg.channel.createMessage("Channel is not on slowmode");
|
||||
msg.channel.send("Channel is not on slowmode");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,6 +3,7 @@ import { slowmodeCmd } from "../types";
|
|||
import { createChunkedMessage } from "knub/dist/helpers";
|
||||
import { errorMessage } from "../../../utils";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildChannel, TextChannel } from "discord.js";
|
||||
|
||||
export const SlowmodeListCmd = slowmodeCmd({
|
||||
trigger: ["slowmode list", "slowmode l", "slowmodes"],
|
||||
|
@ -12,7 +13,7 @@ export const SlowmodeListCmd = slowmodeCmd({
|
|||
const channels = pluginData.guild.channels;
|
||||
const slowmodes: Array<{ channel: GuildChannel; seconds: number; native: boolean }> = [];
|
||||
|
||||
for (const channel of channels.values()) {
|
||||
for (const channel of channels.cache.values()) {
|
||||
if (!(channel instanceof TextChannel)) continue;
|
||||
|
||||
// Bot slowmode
|
||||
|
@ -40,7 +41,7 @@ export const SlowmodeListCmd = slowmodeCmd({
|
|||
|
||||
createChunkedMessage(msg.channel, lines.join("\n"));
|
||||
} else {
|
||||
msg.channel.createMessage(errorMessage("No active slowmodes!"));
|
||||
msg.channel.send(errorMessage("No active slowmodes!"));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ import { actualDisableSlowmodeCmd } from "../util/actualDisableSlowmodeCmd";
|
|||
import { getMissingPermissions } from "../../../utils/getMissingPermissions";
|
||||
import { missingPermissionError } from "../../../utils/missingPermissionError";
|
||||
import { BOT_SLOWMODE_PERMISSIONS, NATIVE_SLOWMODE_PERMISSIONS } from "../requiredPermissions";
|
||||
import { Permissions, TextChannel } from "discord.js";
|
||||
|
||||
const MAX_NATIVE_SLOWMODE = 6 * HOURS; // 6 hours
|
||||
const MAX_BOT_SLOWMODE = DAYS * 365 * 100; // 100 years
|
||||
|
@ -84,10 +85,13 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
}
|
||||
|
||||
// Verify permissions
|
||||
const channelPermissions = channel.permissionsOf(pluginData.client.user!.id);
|
||||
const channelPermissions = channel.permissionsFor(pluginData.client.user!.id);
|
||||
|
||||
if (mode === "native") {
|
||||
const missingPermissions = getMissingPermissions(channelPermissions, NATIVE_SLOWMODE_PERMISSIONS);
|
||||
const missingPermissions = getMissingPermissions(
|
||||
channelPermissions ? channelPermissions : new Permissions(),
|
||||
NATIVE_SLOWMODE_PERMISSIONS,
|
||||
);
|
||||
if (missingPermissions) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
|
@ -99,7 +103,10 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
}
|
||||
|
||||
if (mode === "bot") {
|
||||
const missingPermissions = getMissingPermissions(channelPermissions, BOT_SLOWMODE_PERMISSIONS);
|
||||
const missingPermissions = getMissingPermissions(
|
||||
channelPermissions ? channelPermissions : new Permissions(),
|
||||
BOT_SLOWMODE_PERMISSIONS,
|
||||
);
|
||||
if (missingPermissions) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue