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

Update to Knub30.0.0-beta.37 and Eris 0.15, first pass

This commit is contained in:
Dragory 2021-05-23 14:35:16 +03:00
parent 84da543205
commit f6be4f4af6
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
133 changed files with 6507 additions and 380 deletions

View file

@ -35,7 +35,8 @@ const defaultOptions: PluginOptions<SlowmodePluginType> = {
],
};
export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()("slowmode", {
export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()({
name: "slowmode",
showInDocs: true,
info: {
prettyName: "Slowmode",
@ -54,7 +55,7 @@ export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()("slowmod
SlowmodeSetCmd,
],
onLoad(pluginData) {
afterLoad(pluginData) {
const { state, guild } = pluginData;
state.slowmodes = GuildSlowmodes.getGuildInstance(guild.id);
@ -66,7 +67,7 @@ export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()("slowmod
state.savedMessages.events.on("create", state.onMessageCreateFn);
},
onUnload(pluginData) {
beforeUnload(pluginData) {
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
},
});

View file

@ -46,7 +46,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
}
const defaultMode: TMode =
pluginData.config.getForChannel(channel).use_native_slowmode && args.time <= MAX_NATIVE_SLOWMODE
(await pluginData.config.getForChannel(channel)).use_native_slowmode && args.time <= MAX_NATIVE_SLOWMODE
? "native"
: "bot";

View file

@ -1,5 +1,5 @@
import * as t from "io-ts";
import { BasePluginType, guildCommand, guildEventListener } from "knub";
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
import { GuildSlowmodes } from "../../data/GuildSlowmodes";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildLogs } from "../../data/GuildLogs";
@ -24,5 +24,5 @@ export interface SlowmodePluginType extends BasePluginType {
};
}
export const slowmodeCmd = guildCommand<SlowmodePluginType>();
export const slowmodeEvt = guildEventListener<SlowmodePluginType>();
export const slowmodeCmd = typedGuildCommand<SlowmodePluginType>();
export const slowmodeEvt = typedGuildEventListener<SlowmodePluginType>();

View file

@ -12,8 +12,8 @@ export async function applyBotSlowmodeToUserId(
) {
// Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account.
const existingOverride = channel.permissionOverwrites.get(userId);
const newDeniedPermissions = (existingOverride ? existingOverride.deny : 0) | Constants.Permissions.sendMessages;
const newAllowedPermissions = (existingOverride ? existingOverride.allow : 0) & ~Constants.Permissions.sendMessages;
const newDeniedPermissions = (existingOverride ? existingOverride.deny : 0n) | Constants.Permissions.sendMessages;
const newAllowedPermissions = (existingOverride ? existingOverride.allow : 0n) & ~Constants.Permissions.sendMessages;
try {
await channel.editPermission(userId, newAllowedPermissions, newDeniedPermissions, "member");

View file

@ -28,7 +28,11 @@ export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePlugin
// Make sure this user is affected by the slowmode
const member = await resolveMember(pluginData.client, pluginData.guild, msg.user_id);
const isAffected = hasPermission(pluginData, "is_affected", { channelId: channel.id, userId: msg.user_id, member });
const isAffected = await hasPermission(pluginData, "is_affected", {
channelId: channel.id,
userId: msg.user_id,
member,
});
if (!isAffected) return thisMsgLock.unlock();
// Make sure we have the appropriate permissions to manage this slowmode