mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 12:55:01 +00:00
Update djs & knub (#395)
* update pkgs
Signed-off-by: GitHub <noreply@github.com>
* new knub typings
Signed-off-by: GitHub <noreply@github.com>
* more pkg updates
Signed-off-by: GitHub <noreply@github.com>
* more fixes
Signed-off-by: GitHub <noreply@github.com>
* channel typings
Signed-off-by: GitHub <noreply@github.com>
* more message utils typings fixes
Signed-off-by: GitHub <noreply@github.com>
* migrate permissions
Signed-off-by: GitHub <noreply@github.com>
* fix: InternalPoster webhookables
Signed-off-by: GitHub <noreply@github.com>
* djs typings: Attachment & Util
Signed-off-by: GitHub <noreply@github.com>
* more typings
Signed-off-by: GitHub <noreply@github.com>
* fix: rename permissionNames
Signed-off-by: GitHub <noreply@github.com>
* more fixes
Signed-off-by: GitHub <noreply@github.com>
* half the number of errors
* knub commands => messageCommands
Signed-off-by: GitHub <noreply@github.com>
* configPreprocessor => configParser
Signed-off-by: GitHub <noreply@github.com>
* fix channel.messages
Signed-off-by: GitHub <noreply@github.com>
* revert automod any typing
Signed-off-by: GitHub <noreply@github.com>
* more configParser typings
Signed-off-by: GitHub <noreply@github.com>
* revert
Signed-off-by: GitHub <noreply@github.com>
* remove knub type params
Signed-off-by: GitHub <noreply@github.com>
* fix more MessageEmbed / MessageOptions
Signed-off-by: GitHub <noreply@github.com>
* dumb commit for @almeidx to see why this is stupid
Signed-off-by: GitHub <noreply@github.com>
* temp disable custom_events
Signed-off-by: GitHub <noreply@github.com>
* more minor typings fixes - 23 err left
Signed-off-by: GitHub <noreply@github.com>
* update djs dep
* +debug build method (revert this)
Signed-off-by: GitHub <noreply@github.com>
* Revert "+debug build method (revert this)"
This reverts commit a80af1e729
.
* Redo +debug build (Revert this)
Signed-off-by: GitHub <noreply@github.com>
* uniform before/after Load shorthands
Signed-off-by: GitHub <noreply@github.com>
* remove unused imports & add prettier plugin
Signed-off-by: GitHub <noreply@github.com>
* env fixes for web platform hosting
Signed-off-by: GitHub <noreply@github.com>
* feat: knub v32-next; related fixes
* fix: allow legacy keys in change_perms action
* fix: request Message Content intent
* fix: use Knub's config validation logic in API
* fix(dashboard): fix error when there are no message and/or slash commands in a plugin
* fix(automod): start_thread action thread options
* fix(CustomEvents): message command types
* chore: remove unneeded type annotation
* feat: add forum channel icon; use thread icon for news threads
* chore: make tslint happy
* chore: fix formatting
---------
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: almeidx <almeidx@pm.me>
Co-authored-by: Dragory <2606411+Dragory@users.noreply.github.com>
This commit is contained in:
parent
293115af22
commit
06877e90cc
476 changed files with 2965 additions and 3251 deletions
|
@ -1,5 +1,4 @@
|
|||
import { Util } from "discord.js";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { ChannelType, escapeInlineCode } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { asSingleLine } from "../../../utils";
|
||||
|
@ -39,7 +38,7 @@ export const SlowmodeClearCmd = slowmodeCmd({
|
|||
}
|
||||
|
||||
try {
|
||||
if (args.channel.type === ChannelTypeStrings.TEXT) {
|
||||
if (args.channel.type === ChannelType.GuildText) {
|
||||
await clearBotSlowmodeFromUserId(pluginData, args.channel, args.user.id, args.force);
|
||||
} else {
|
||||
sendErrorMessage(
|
||||
|
@ -58,7 +57,7 @@ export const SlowmodeClearCmd = slowmodeCmd({
|
|||
msg.channel,
|
||||
asSingleLine(`
|
||||
Failed to clear slowmode from **${args.user.tag}** in <#${args.channel.id}>:
|
||||
\`${Util.escapeInlineCode(e.message)}\`
|
||||
\`${escapeInlineCode(e.message)}\`
|
||||
`),
|
||||
);
|
||||
return;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildChannel, TextChannel } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { createChunkedMessage } from "knub/dist/helpers";
|
||||
import { createChunkedMessage } from "knub/helpers";
|
||||
import { errorMessage } from "../../../utils";
|
||||
import { slowmodeCmd } from "../types";
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Permissions, TextChannel, ThreadChannel, Util } from "discord.js";
|
||||
import { escapeInlineCode, PermissionsBitField } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { asSingleLine, DAYS, HOURS, MINUTES } from "../../../utils";
|
||||
|
@ -23,7 +22,6 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
permission: "can_manage",
|
||||
source: "guild",
|
||||
|
||||
// prettier-ignore
|
||||
signature: [
|
||||
{
|
||||
time: ct.delay(),
|
||||
|
@ -35,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: TextChannel | ThreadChannel = 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
|
||||
|
@ -89,7 +92,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
|
||||
if (mode === "native") {
|
||||
const missingPermissions = getMissingPermissions(
|
||||
channelPermissions ?? new Permissions(),
|
||||
channelPermissions ?? new PermissionsBitField(),
|
||||
NATIVE_SLOWMODE_PERMISSIONS,
|
||||
);
|
||||
if (missingPermissions) {
|
||||
|
@ -104,7 +107,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
|
||||
if (mode === "bot") {
|
||||
const missingPermissions = getMissingPermissions(
|
||||
channelPermissions ?? new Permissions(),
|
||||
channelPermissions ?? new PermissionsBitField(),
|
||||
BOT_SLOWMODE_PERMISSIONS,
|
||||
);
|
||||
if (missingPermissions) {
|
||||
|
@ -123,25 +126,21 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
if (mode === "native") {
|
||||
// If there is an existing bot-maintained slowmode, disable that first
|
||||
const existingBotSlowmode = await pluginData.state.slowmodes.getChannelSlowmode(channel.id);
|
||||
if (existingBotSlowmode && channel.type === ChannelTypeStrings.TEXT) {
|
||||
if (existingBotSlowmode && channel.isTextBased()) {
|
||||
await disableBotSlowmodeForChannel(pluginData, channel);
|
||||
}
|
||||
|
||||
// Set native slowmode
|
||||
try {
|
||||
await channel.edit({
|
||||
rateLimitPerUser: rateLimitSeconds,
|
||||
});
|
||||
await channel.setRateLimitPerUser(rateLimitSeconds);
|
||||
} catch (e) {
|
||||
sendErrorMessage(pluginData, msg.channel, `Failed to set native slowmode: ${Util.escapeInlineCode(e.message)}`);
|
||||
sendErrorMessage(pluginData, msg.channel, `Failed to set native slowmode: ${escapeInlineCode(e.message)}`);
|
||||
return;
|
||||
}
|
||||
} 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
|
||||
|
@ -149,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue