mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Update to Knub30.0.0-beta.37 and Eris 0.15, first pass
This commit is contained in:
parent
84da543205
commit
f6be4f4af6
133 changed files with 6507 additions and 380 deletions
6126
backend/package-lock.json
generated
6126
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -31,7 +31,7 @@
|
|||
"deep-diff": "^1.0.2",
|
||||
"dotenv": "^4.0.0",
|
||||
"emoji-regex": "^8.0.0",
|
||||
"eris": "github:abalabahaha/eris#dev",
|
||||
"eris": "^0.15.1",
|
||||
"erlpack": "github:abalabahaha/erlpack",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
"express": "^4.17.0",
|
||||
|
@ -39,7 +39,7 @@
|
|||
"humanize-duration": "^3.15.0",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^30.0.0-beta.35",
|
||||
"knub": "^30.0.0-beta.37",
|
||||
"knub-command-manager": "^8.1.2",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
UnknownUser,
|
||||
} from "./utils";
|
||||
import { GuildChannel, Member, TextChannel, User } from "eris";
|
||||
import { baseTypeConverters, baseTypeHelpers, CommandContext, TypeConversionError } from "knub";
|
||||
import { baseTypeConverters, baseCommandParameterTypeHelpers, CommandContext, TypeConversionError } from "knub";
|
||||
import { createTypeHelper } from "knub-command-manager";
|
||||
import { getChannelIdFromMessageId } from "./data/getChannelIdFromMessageId";
|
||||
import { MessageTarget, resolveMessageTarget } from "./utils/resolveMessageTarget";
|
||||
|
@ -107,7 +107,7 @@ export const commandTypes = {
|
|||
};
|
||||
|
||||
export const commandTypeHelpers = {
|
||||
...baseTypeHelpers,
|
||||
...baseCommandParameterTypeHelpers,
|
||||
|
||||
delay: createTypeHelper<number>(commandTypes.delay),
|
||||
resolvedUser: createTypeHelper<Promise<User>>(commandTypes.resolvedUser),
|
||||
|
|
|
@ -37,7 +37,7 @@ export async function validateGuildConfig(config: any): Promise<string | null> {
|
|||
const plugin = pluginNameToPlugin.get(pluginName)!;
|
||||
try {
|
||||
const mergedOptions = configUtils.mergeConfig(plugin.defaultOptions || {}, pluginOptions);
|
||||
await plugin.configPreprocessor?.(mergedOptions as PluginOptions<any>);
|
||||
await plugin.configPreprocessor?.((mergedOptions as unknown) as PluginOptions<any>);
|
||||
} catch (err) {
|
||||
if (err instanceof ConfigValidationError || err instanceof StrictValidationError) {
|
||||
return `${pluginName}: ${err.message}`;
|
||||
|
|
|
@ -2,7 +2,7 @@ import { getRepository, Repository } from "typeorm";
|
|||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { ISavedMessageData, SavedMessage } from "./entities/SavedMessage";
|
||||
import { QueuedEventEmitter } from "../QueuedEventEmitter";
|
||||
import { GuildChannel, Message } from "eris";
|
||||
import { GuildChannel, Message, PossiblyUncachedTextableChannel } from "eris";
|
||||
import moment from "moment-timezone";
|
||||
import { MINUTES, SECONDS } from "../utils";
|
||||
import { isAPI } from "../globals";
|
||||
|
@ -34,7 +34,7 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
this.toBePermanent = new Set();
|
||||
}
|
||||
|
||||
public msgToSavedMessageData(msg: Message): ISavedMessageData {
|
||||
public msgToSavedMessageData(msg: Message<PossiblyUncachedTextableChannel>): ISavedMessageData {
|
||||
const data: ISavedMessageData = {
|
||||
author: {
|
||||
username: msg.author.username,
|
||||
|
@ -139,7 +139,7 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
this.events.emit(`create:${data.id}`, [inserted]);
|
||||
}
|
||||
|
||||
async createFromMsg(msg: Message, overrides = {}) {
|
||||
async createFromMsg(msg: Message<PossiblyUncachedTextableChannel>, overrides = {}) {
|
||||
const existingSavedMsg = await this.find(msg.id);
|
||||
if (existingSavedMsg) return;
|
||||
|
||||
|
@ -222,7 +222,7 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
this.events.emit(`update:${id}`, [newMessage, oldMessage]);
|
||||
}
|
||||
|
||||
async saveEditFromMsg(msg: Message) {
|
||||
async saveEditFromMsg(msg: Message<PossiblyUncachedTextableChannel>) {
|
||||
const newData = this.msgToSavedMessageData(msg);
|
||||
return this.saveEdit(msg.id, newData);
|
||||
}
|
||||
|
|
|
@ -27,8 +27,12 @@ export function canActOn(pluginData: GuildPluginData<any>, member1: Member, memb
|
|||
return allowSameLevel ? ourLevel >= memberLevel : ourLevel > memberLevel;
|
||||
}
|
||||
|
||||
export function hasPermission(pluginData: AnyPluginData<any>, permission: string, matchParams: ExtendedMatchParams) {
|
||||
const config = pluginData.config.getMatchingConfig(matchParams);
|
||||
export async function hasPermission(
|
||||
pluginData: AnyPluginData<any>,
|
||||
permission: string,
|
||||
matchParams: ExtendedMatchParams,
|
||||
) {
|
||||
const config = await pluginData.config.getMatchingConfig(matchParams);
|
||||
return helpers.hasPermission(config, permission);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ const defaultOptions: PluginOptions<AutoDeletePluginType> = {
|
|||
},
|
||||
};
|
||||
|
||||
export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()("auto_delete", {
|
||||
export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()({
|
||||
name: "auto_delete",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Auto-delete",
|
||||
|
@ -28,7 +29,7 @@ export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()("aut
|
|||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.guildSavedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||
|
@ -50,7 +51,7 @@ export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()("aut
|
|||
state.guildSavedMessages.events.on("deleteBulk", state.onMessageDeleteBulkFn);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
pluginData.state.guildSavedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
||||
pluginData.state.guildSavedMessages.events.off("delete", pluginData.state.onMessageDeleteFn);
|
||||
pluginData.state.guildSavedMessages.events.off("deleteBulk", pluginData.state.onMessageDeleteBulkFn);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { tDelayString, MINUTES } from "../../utils";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
|
|
|
@ -7,7 +7,7 @@ import { addMessageToDeletionQueue } from "./addMessageToDeletionQueue";
|
|||
|
||||
export async function onMessageCreate(pluginData: GuildPluginData<AutoDeletePluginType>, msg: SavedMessage) {
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, msg.user_id);
|
||||
const config = pluginData.config.getMatchingConfig({ member, channelId: msg.channel_id });
|
||||
const config = await pluginData.config.getMatchingConfig({ member, channelId: msg.channel_id });
|
||||
if (config.enabled) {
|
||||
let delay = convertDelayStringToMS(config.delay)!;
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ const defaultOptions: PluginOptions<AutoReactionsPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const AutoReactionsPlugin = zeppelinGuildPlugin<AutoReactionsPluginType>()("auto_reactions", {
|
||||
export const AutoReactionsPlugin = zeppelinGuildPlugin<AutoReactionsPluginType>()({
|
||||
name: "auto_reactions",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Auto-reactions",
|
||||
|
@ -47,7 +48,7 @@ export const AutoReactionsPlugin = zeppelinGuildPlugin<AutoReactionsPluginType>(
|
|||
AddReactionsEvt,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildAutoReactions } from "../../data/GuildAutoReactions";
|
||||
|
@ -18,5 +18,5 @@ export interface AutoReactionsPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const autoReactionsCmd = guildCommand<AutoReactionsPluginType>();
|
||||
export const autoReactionsEvt = guildEventListener<AutoReactionsPluginType>();
|
||||
export const autoReactionsCmd = typedGuildCommand<AutoReactionsPluginType>();
|
||||
export const autoReactionsEvt = typedGuildEventListener<AutoReactionsPluginType>();
|
||||
|
|
|
@ -152,7 +152,8 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
|
|||
return options;
|
||||
};
|
||||
|
||||
export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()("automod", {
|
||||
export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
||||
name: "automod",
|
||||
showInDocs: true,
|
||||
info: pluginInfo,
|
||||
|
||||
|
@ -181,22 +182,16 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()("automod",
|
|||
|
||||
commands: [AntiraidClearCmd, SetAntiraidCmd, ViewAntiraidCmd],
|
||||
|
||||
async onLoad(pluginData) {
|
||||
async beforeLoad(pluginData) {
|
||||
pluginData.state.queue = new Queue();
|
||||
|
||||
pluginData.state.regexRunner = getRegExpRunner(`guild-${pluginData.guild.id}`);
|
||||
|
||||
pluginData.state.recentActions = [];
|
||||
pluginData.state.clearRecentActionsInterval = setInterval(() => clearOldRecentActions(pluginData), 1 * MINUTES);
|
||||
|
||||
pluginData.state.recentSpam = [];
|
||||
pluginData.state.clearRecentSpamInterval = setInterval(() => clearOldRecentSpam(pluginData), 1 * SECONDS);
|
||||
|
||||
pluginData.state.recentNicknameChanges = new Map();
|
||||
pluginData.state.clearRecentNicknameChangesInterval = setInterval(
|
||||
() => clearOldRecentNicknameChanges(pluginData),
|
||||
30 * SECONDS,
|
||||
);
|
||||
|
||||
pluginData.state.ignoredRoleChanges = new Set();
|
||||
|
||||
|
@ -207,16 +202,23 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()("automod",
|
|||
pluginData.state.antiraidLevels = GuildAntiraidLevels.getGuildInstance(pluginData.guild.id);
|
||||
pluginData.state.archives = GuildArchives.getGuildInstance(pluginData.guild.id);
|
||||
|
||||
pluginData.state.cachedAntiraidLevel = await pluginData.state.antiraidLevels.get();
|
||||
},
|
||||
|
||||
async afterLoad(pluginData) {
|
||||
pluginData.state.clearRecentActionsInterval = setInterval(() => clearOldRecentActions(pluginData), 1 * MINUTES);
|
||||
pluginData.state.clearRecentSpamInterval = setInterval(() => clearOldRecentSpam(pluginData), 1 * SECONDS);
|
||||
pluginData.state.clearRecentNicknameChangesInterval = setInterval(
|
||||
() => clearOldRecentNicknameChanges(pluginData),
|
||||
30 * SECONDS,
|
||||
);
|
||||
|
||||
pluginData.state.onMessageCreateFn = message => runAutomodOnMessage(pluginData, message, false);
|
||||
pluginData.state.savedMessages.events.on("create", pluginData.state.onMessageCreateFn);
|
||||
|
||||
pluginData.state.onMessageUpdateFn = message => runAutomodOnMessage(pluginData, message, true);
|
||||
pluginData.state.savedMessages.events.on("update", pluginData.state.onMessageUpdateFn);
|
||||
|
||||
pluginData.state.cachedAntiraidLevel = await pluginData.state.antiraidLevels.get();
|
||||
},
|
||||
|
||||
async onAfterLoad(pluginData) {
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
|
||||
pluginData.state.onCounterTrigger = (name, triggerName, channelId, userId) => {
|
||||
|
@ -268,7 +270,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()("automod",
|
|||
registerEventListenersFromMap(mutesEvents, pluginData.state.mutesListeners);
|
||||
},
|
||||
|
||||
async onBeforeUnload(pluginData) {
|
||||
async beforeUnload(pluginData) {
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
countersPlugin.offCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
||||
countersPlugin.offCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
||||
|
@ -278,9 +280,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()("automod",
|
|||
|
||||
const mutesEvents = pluginData.getPlugin(MutesPlugin).getEventEmitter();
|
||||
unregisterEventListenersFromMap(mutesEvents, pluginData.state.mutesListeners);
|
||||
},
|
||||
|
||||
async onUnload(pluginData) {
|
||||
pluginData.state.queue.clear();
|
||||
|
||||
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { guildCommand, GuildPluginData } from "knub";
|
||||
import { typedGuildCommand, GuildPluginData } from "knub";
|
||||
import { AutomodPluginType } from "../types";
|
||||
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
||||
import { sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
export const AntiraidClearCmd = guildCommand<AutomodPluginType>()({
|
||||
export const AntiraidClearCmd = typedGuildCommand<AutomodPluginType>()({
|
||||
trigger: ["antiraid clear", "antiraid reset", "antiraid none", "antiraid off"],
|
||||
permission: "can_set_antiraid",
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { guildCommand, GuildPluginData } from "knub";
|
||||
import { typedGuildCommand, GuildPluginData } from "knub";
|
||||
import { AutomodPluginType } from "../types";
|
||||
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
||||
export const SetAntiraidCmd = guildCommand<AutomodPluginType>()({
|
||||
export const SetAntiraidCmd = typedGuildCommand<AutomodPluginType>()({
|
||||
trigger: "antiraid",
|
||||
permission: "can_set_antiraid",
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { guildCommand, GuildPluginData } from "knub";
|
||||
import { typedGuildCommand, GuildPluginData } from "knub";
|
||||
import { AutomodPluginType } from "../types";
|
||||
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
||||
export const ViewAntiraidCmd = guildCommand<AutomodPluginType>()({
|
||||
export const ViewAntiraidCmd = typedGuildCommand<AutomodPluginType>()({
|
||||
trigger: "antiraid",
|
||||
permission: "can_view_antiraid",
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { guildEventListener } from "knub";
|
||||
import { typedGuildEventListener } from "knub";
|
||||
import { AutomodContext, AutomodPluginType } from "../types";
|
||||
import { runAutomod } from "../functions/runAutomod";
|
||||
import { RecentActionType } from "../constants";
|
||||
|
||||
export const RunAutomodOnJoinEvt = guildEventListener<AutomodPluginType>()(
|
||||
"guildMemberAdd",
|
||||
({ pluginData, args: { member } }) => {
|
||||
export const RunAutomodOnJoinEvt = typedGuildEventListener<AutomodPluginType>()({
|
||||
event: "guildMemberAdd",
|
||||
listener({ pluginData, args: { member } }) {
|
||||
const context: AutomodContext = {
|
||||
timestamp: Date.now(),
|
||||
user: member.user,
|
||||
|
@ -24,4 +24,4 @@ export const RunAutomodOnJoinEvt = guildEventListener<AutomodPluginType>()(
|
|||
runAutomod(pluginData, context);
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { guildEventListener } from "knub";
|
||||
import { typedGuildEventListener } from "knub";
|
||||
import { AutomodContext, AutomodPluginType } from "../types";
|
||||
import { RecentActionType } from "../constants";
|
||||
import { runAutomod } from "../functions/runAutomod";
|
||||
import isEqual from "lodash.isequal";
|
||||
import diff from "lodash.difference";
|
||||
|
||||
export const RunAutomodOnMemberUpdate = guildEventListener<AutomodPluginType>()(
|
||||
"guildMemberUpdate",
|
||||
({ pluginData, args: { member, oldMember } }) => {
|
||||
export const RunAutomodOnMemberUpdate = typedGuildEventListener<AutomodPluginType>()({
|
||||
event: "guildMemberUpdate",
|
||||
listener({ pluginData, args: { member, oldMember } }) {
|
||||
if (!oldMember) return;
|
||||
|
||||
if (isEqual(oldMember.roles, member.roles)) return;
|
||||
|
@ -31,4 +31,4 @@ export const RunAutomodOnMemberUpdate = guildEventListener<AutomodPluginType>()(
|
|||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>,
|
|||
const channel = channelId ? (pluginData.guild.channels.get(channelId) as TextChannel) : null;
|
||||
const categoryId = channel?.parentID;
|
||||
|
||||
const config = pluginData.config.getMatchingConfig({
|
||||
const config = await pluginData.config.getMatchingConfig({
|
||||
channelId,
|
||||
categoryId,
|
||||
userId,
|
||||
|
|
|
@ -27,7 +27,8 @@ const defaultOptions = {
|
|||
},
|
||||
};
|
||||
|
||||
export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()("bot_control", {
|
||||
export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
||||
name: "bot_control",
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
|
@ -46,7 +47,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()("bo
|
|||
EligibleCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
pluginData.state.archives = new GuildArchives(0);
|
||||
pluginData.state.allowedGuilds = new AllowedGuilds();
|
||||
pluginData.state.configs = new Configs();
|
||||
|
|
|
@ -2,7 +2,8 @@ import { botControlCmd } from "../types";
|
|||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { resolveUser } from "../../../utils";
|
||||
import { resolveUser, UnknownUser } from "../../../utils";
|
||||
import { User } from "eris";
|
||||
|
||||
export const ListDashboardUsersCmd = botControlCmd({
|
||||
trigger: ["list_dashboard_users"],
|
||||
|
|
|
@ -16,6 +16,6 @@ export const ReloadGlobalPluginsCmd = botControlCmd({
|
|||
setActiveReload((message.channel as TextChannel).guild?.id, message.channel.id);
|
||||
await message.channel.createMessage("Reloading global plugins...");
|
||||
|
||||
pluginData.getKnubInstance().reloadAllGlobalPlugins();
|
||||
pluginData.getKnubInstance().reloadGlobalContext();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { tNullable } from "../../utils";
|
||||
import { BasePluginType, globalCommand, globalEventListener } from "knub";
|
||||
import { BasePluginType, typedGlobalCommand, typedGlobalEventListener } from "knub";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
|
@ -23,5 +23,5 @@ export interface BotControlPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const botControlCmd = globalCommand<BotControlPluginType>();
|
||||
export const botControlEvt = globalEventListener<BotControlPluginType>();
|
||||
export const botControlCmd = typedGlobalCommand<BotControlPluginType>();
|
||||
export const botControlEvt = typedGlobalEventListener<BotControlPluginType>();
|
||||
|
|
|
@ -28,7 +28,8 @@ const defaultOptions = {
|
|||
},
|
||||
};
|
||||
|
||||
export const CasesPlugin = zeppelinGuildPlugin<CasesPluginType>()("cases", {
|
||||
export const CasesPlugin = zeppelinGuildPlugin<CasesPluginType>()({
|
||||
name: "cases",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Cases",
|
||||
|
@ -73,7 +74,7 @@ export const CasesPlugin = zeppelinGuildPlugin<CasesPluginType>()("cases", {
|
|||
getCaseSummary: mapToPublicFn(getCaseSummary),
|
||||
},
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
pluginData.state.logs = new GuildLogs(pluginData.guild.id);
|
||||
pluginData.state.archives = GuildArchives.getGuildInstance(pluginData.guild.id);
|
||||
pluginData.state.cases = GuildCases.getGuildInstance(pluginData.guild.id);
|
||||
|
|
|
@ -46,7 +46,7 @@ export async function createCaseNote(pluginData: GuildPluginData<CasesPluginType
|
|||
}
|
||||
}
|
||||
|
||||
const modConfig = pluginData.config.getForUser(mod);
|
||||
const modConfig = await pluginData.config.getForUser(mod);
|
||||
if (
|
||||
args.postInCaseLogOverride === true ||
|
||||
((!args.automatic || modConfig.log_automatic_actions) && args.postInCaseLogOverride !== false)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as t from "io-ts";
|
||||
import { tDelayString, tPartialDictionary, tNullable } from "../../utils";
|
||||
import { CaseNameToType, CaseTypes } from "../../data/CaseTypes";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
|
|
|
@ -43,7 +43,8 @@ const defaultOptions: PluginOptions<CensorPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()("censor", {
|
||||
export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()({
|
||||
name: "censor",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Censor",
|
||||
|
@ -57,7 +58,7 @@ export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()("censor", {
|
|||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.serverLogs = new GuildLogs(guild.id);
|
||||
|
@ -72,7 +73,7 @@ export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()("censor", {
|
|||
state.savedMessages.events.on("update", state.onMessageUpdateFn);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
||||
|
||||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
||||
|
|
|
@ -15,7 +15,7 @@ export async function applyFiltersToMsg(
|
|||
savedMessage: SavedMessage,
|
||||
): Promise<boolean> {
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, savedMessage.user_id);
|
||||
const config = pluginData.config.getMatchingConfig({ member, channelId: savedMessage.channel_id });
|
||||
const config = await pluginData.config.getMatchingConfig({ member, channelId: savedMessage.channel_id });
|
||||
|
||||
let messageContent = savedMessage.data.content || "";
|
||||
if (savedMessage.data.attachments) messageContent += " " + JSON.stringify(savedMessage.data.attachments);
|
||||
|
|
|
@ -4,7 +4,8 @@ import { ArchiveChannelCmd } from "./commands/ArchiveChannelCmd";
|
|||
import * as t from "io-ts";
|
||||
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
|
||||
|
||||
export const ChannelArchiverPlugin = zeppelinGuildPlugin<ChannelArchiverPluginType>()("channel_archiver", {
|
||||
export const ChannelArchiverPlugin = zeppelinGuildPlugin<ChannelArchiverPluginType>()({
|
||||
name: "channel_archiver",
|
||||
showInDocs: false,
|
||||
|
||||
dependencies: [TimeAndDatePlugin],
|
||||
|
@ -15,7 +16,7 @@ export const ChannelArchiverPlugin = zeppelinGuildPlugin<ChannelArchiverPluginTy
|
|||
ArchiveChannelCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BasePluginType, guildCommand } from "knub";
|
||||
import { BasePluginType, typedGuildCommand } from "knub";
|
||||
|
||||
export interface ChannelArchiverPluginType extends BasePluginType {
|
||||
state: {};
|
||||
}
|
||||
|
||||
export const channelArchiverCmd = guildCommand<ChannelArchiverPluginType>();
|
||||
export const channelArchiverCmd = typedGuildCommand<ChannelArchiverPluginType>();
|
||||
|
|
|
@ -13,7 +13,8 @@ const defaultOptions = {
|
|||
},
|
||||
};
|
||||
|
||||
export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPluginType>()("companion_channels", {
|
||||
export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPluginType>()({
|
||||
name: "companion_channels",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Companion channels",
|
||||
|
@ -30,7 +31,7 @@ export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPlug
|
|||
|
||||
events: [VoiceChannelJoinEvt, VoiceChannelSwitchEvt, VoiceChannelLeaveEvt],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
pluginData.state.errorCooldownManager = new CooldownManager();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,9 +2,9 @@ import { companionChannelsEvt } from "../types";
|
|||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
import { stripObjectToScalars } from "../../../utils";
|
||||
|
||||
export const VoiceChannelJoinEvt = companionChannelsEvt(
|
||||
"voiceChannelJoin",
|
||||
({ pluginData, args: { member, newChannel } }) => {
|
||||
export const VoiceChannelJoinEvt = companionChannelsEvt({
|
||||
event: "voiceChannelJoin",
|
||||
listener({ pluginData, args: { member, newChannel } }) {
|
||||
handleCompanionPermissions(pluginData, member.id, newChannel);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { companionChannelsEvt } from "../types";
|
||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
|
||||
export const VoiceChannelLeaveEvt = companionChannelsEvt(
|
||||
"voiceChannelLeave",
|
||||
({ pluginData, args: { member, oldChannel } }) => {
|
||||
export const VoiceChannelLeaveEvt = companionChannelsEvt({
|
||||
event: "voiceChannelLeave",
|
||||
listener({ pluginData, args: { member, oldChannel } }) {
|
||||
handleCompanionPermissions(pluginData, member.id, null, oldChannel);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { companionChannelsEvt } from "../types";
|
||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
|
||||
export const VoiceChannelSwitchEvt = companionChannelsEvt(
|
||||
"voiceChannelSwitch",
|
||||
({ pluginData, args: { member, oldChannel, newChannel } }) => {
|
||||
export const VoiceChannelSwitchEvt = companionChannelsEvt({
|
||||
event: "voiceChannelSwitch",
|
||||
listener({ pluginData, args: { member, oldChannel, newChannel } }) {
|
||||
handleCompanionPermissions(pluginData, member.id, newChannel, oldChannel);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -6,12 +6,12 @@ const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
|||
enabled: true,
|
||||
};
|
||||
|
||||
export function getCompanionChannelOptsForVoiceChannelId(
|
||||
export async function getCompanionChannelOptsForVoiceChannelId(
|
||||
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannel: VoiceChannel,
|
||||
): TCompanionChannelOpts[] {
|
||||
const config = pluginData.config.getMatchingConfig({ userId, channelId: voiceChannel.id });
|
||||
): Promise<TCompanionChannelOpts[]> {
|
||||
const config = await pluginData.config.getMatchingConfig({ userId, channelId: voiceChannel.id });
|
||||
return Object.values(config.entries)
|
||||
.filter(
|
||||
opts =>
|
||||
|
|
|
@ -36,10 +36,10 @@ export async function handleCompanionPermissions(
|
|||
const permsToSet: Map<string, number> = new Map(); // channelId => permissions
|
||||
|
||||
const oldChannelOptsArr: TCompanionChannelOpts[] = oldChannel
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, oldChannel)
|
||||
? await getCompanionChannelOptsForVoiceChannelId(pluginData, userId, oldChannel)
|
||||
: [];
|
||||
const newChannelOptsArr: TCompanionChannelOpts[] = voiceChannel
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, voiceChannel)
|
||||
? await getCompanionChannelOptsForVoiceChannelId(pluginData, userId, voiceChannel)
|
||||
: [];
|
||||
|
||||
for (const oldChannelOpts of oldChannelOptsArr) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { tNullable } from "../../utils";
|
||||
import { BasePluginType, CooldownManager, guildEventListener } from "knub";
|
||||
import { BasePluginType, CooldownManager, typedGuildEventListener } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
|
||||
|
@ -29,4 +29,4 @@ export interface CompanionChannelsPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const companionChannelsEvt = guildEventListener<CompanionChannelsPluginType>();
|
||||
export const companionChannelsEvt = typedGuildEventListener<CompanionChannelsPluginType>();
|
||||
|
|
|
@ -106,7 +106,8 @@ const configPreprocessor: ConfigPreprocessorFn<CountersPluginType> = options =>
|
|||
* A single trigger can only trigger once per user/channel/in general, depending on how specific the counter is (e.g. a per-user trigger can only trigger once per user).
|
||||
* After being triggered, a trigger is "reset" if the counter value no longer matches the trigger (e.g. drops to 100 or below in the above example). After this, that trigger can be triggered again.
|
||||
*/
|
||||
export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()("counters", {
|
||||
export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
||||
name: "counters",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Counters",
|
||||
|
@ -145,7 +146,7 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()("counter
|
|||
ResetAllCounterValuesCmd,
|
||||
],
|
||||
|
||||
async onLoad(pluginData) {
|
||||
async afterLoad(pluginData) {
|
||||
pluginData.state.counters = new GuildCounters(pluginData.guild.id);
|
||||
pluginData.state.events = new EventEmitter();
|
||||
pluginData.state.counterTriggersByCounterId = new Map();
|
||||
|
@ -207,7 +208,7 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()("counter
|
|||
}
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
for (const interval of pluginData.state.decayTimers) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { guildCommand } from "knub";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { CountersPluginType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
|
@ -7,7 +7,7 @@ import { TextChannel, User } from "eris";
|
|||
import { resolveUser, UnknownUser } from "../../../utils";
|
||||
import { changeCounterValue } from "../functions/changeCounterValue";
|
||||
|
||||
export const AddCounterCmd = guildCommand<CountersPluginType>()({
|
||||
export const AddCounterCmd = typedGuildCommand<CountersPluginType>()({
|
||||
trigger: ["counters add", "counter add", "addcounter"],
|
||||
permission: "can_edit",
|
||||
|
||||
|
@ -41,7 +41,7 @@ export const AddCounterCmd = guildCommand<CountersPluginType>()({
|
|||
],
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
const config = pluginData.config.getForMessage(message);
|
||||
const config = await pluginData.config.getForMessage(message);
|
||||
const counter = config.counters[args.counterName];
|
||||
const counterId = pluginData.state.counterIds[args.counterName];
|
||||
if (!counter || !counterId) {
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import { guildCommand } from "knub";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { CountersPluginType } from "../types";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { trimMultilineString, ucfirst } from "../../../utils";
|
||||
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
|
||||
|
||||
export const CountersListCmd = guildCommand<CountersPluginType>()({
|
||||
export const CountersListCmd = typedGuildCommand<CountersPluginType>()({
|
||||
trigger: ["counters list", "counter list", "counters"],
|
||||
permission: "can_view",
|
||||
|
||||
signature: {},
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
const config = pluginData.config.getForMessage(message);
|
||||
const config = await pluginData.config.getForMessage(message);
|
||||
|
||||
const countersToShow = Array.from(Object.values(config.counters)).filter(c => c.can_view !== false);
|
||||
if (!countersToShow.length) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { guildCommand } from "knub";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { CountersPluginType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
@ -10,7 +10,7 @@ import { setCounterValue } from "../functions/setCounterValue";
|
|||
import { resetAllCounterValues } from "../functions/resetAllCounterValues";
|
||||
import { counterIdLock } from "../../../utils/lockNameHelpers";
|
||||
|
||||
export const ResetAllCounterValuesCmd = guildCommand<CountersPluginType>()({
|
||||
export const ResetAllCounterValuesCmd = typedGuildCommand<CountersPluginType>()({
|
||||
trigger: ["counters reset_all"],
|
||||
permission: "can_reset_all",
|
||||
|
||||
|
@ -19,7 +19,7 @@ export const ResetAllCounterValuesCmd = guildCommand<CountersPluginType>()({
|
|||
},
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
const config = pluginData.config.getForMessage(message);
|
||||
const config = await pluginData.config.getForMessage(message);
|
||||
const counter = config.counters[args.counterName];
|
||||
const counterId = pluginData.state.counterIds[args.counterName];
|
||||
if (!counter || !counterId) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { guildCommand } from "knub";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { CountersPluginType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
|
@ -7,7 +7,7 @@ import { TextChannel } from "eris";
|
|||
import { resolveUser, UnknownUser } from "../../../utils";
|
||||
import { setCounterValue } from "../functions/setCounterValue";
|
||||
|
||||
export const ResetCounterCmd = guildCommand<CountersPluginType>()({
|
||||
export const ResetCounterCmd = typedGuildCommand<CountersPluginType>()({
|
||||
trigger: ["counters reset", "counter reset", "resetcounter"],
|
||||
permission: "can_edit",
|
||||
|
||||
|
@ -36,7 +36,7 @@ export const ResetCounterCmd = guildCommand<CountersPluginType>()({
|
|||
],
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
const config = pluginData.config.getForMessage(message);
|
||||
const config = await pluginData.config.getForMessage(message);
|
||||
const counter = config.counters[args.counterName];
|
||||
const counterId = pluginData.state.counterIds[args.counterName];
|
||||
if (!counter || !counterId) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { guildCommand } from "knub";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { CountersPluginType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
|
@ -8,7 +8,7 @@ import { resolveUser, UnknownUser } from "../../../utils";
|
|||
import { changeCounterValue } from "../functions/changeCounterValue";
|
||||
import { setCounterValue } from "../functions/setCounterValue";
|
||||
|
||||
export const SetCounterCmd = guildCommand<CountersPluginType>()({
|
||||
export const SetCounterCmd = typedGuildCommand<CountersPluginType>()({
|
||||
trigger: ["counters set", "counter set", "setcounter"],
|
||||
permission: "can_edit",
|
||||
|
||||
|
@ -42,7 +42,7 @@ export const SetCounterCmd = guildCommand<CountersPluginType>()({
|
|||
],
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
const config = pluginData.config.getForMessage(message);
|
||||
const config = await pluginData.config.getForMessage(message);
|
||||
const counter = config.counters[args.counterName];
|
||||
const counterId = pluginData.state.counterIds[args.counterName];
|
||||
if (!counter || !counterId) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { guildCommand } from "knub";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { CountersPluginType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
|
@ -6,7 +6,7 @@ import { resolveChannel, waitForReply } from "knub/dist/helpers";
|
|||
import { TextChannel, User } from "eris";
|
||||
import { resolveUser, UnknownUser } from "../../../utils";
|
||||
|
||||
export const ViewCounterCmd = guildCommand<CountersPluginType>()({
|
||||
export const ViewCounterCmd = typedGuildCommand<CountersPluginType>()({
|
||||
trigger: ["counters view", "counter view", "viewcounter", "counter"],
|
||||
permission: "can_view",
|
||||
|
||||
|
@ -35,7 +35,7 @@ export const ViewCounterCmd = guildCommand<CountersPluginType>()({
|
|||
],
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
const config = pluginData.config.getForMessage(message);
|
||||
const config = await pluginData.config.getForMessage(message);
|
||||
const counter = config.counters[args.counterName];
|
||||
const counterId = pluginData.state.counterIds[args.counterName];
|
||||
if (!counter || !counterId) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { ConfigSchema, CustomEventsPluginType } from "./types";
|
||||
import { guildCommand, parseSignature } from "knub";
|
||||
import { typedGuildCommand, parseSignature } from "knub";
|
||||
import { commandTypes } from "../../commandTypes";
|
||||
import { stripObjectToScalars } from "../../utils";
|
||||
import { runEvent } from "./functions/runEvent";
|
||||
|
@ -11,18 +11,19 @@ const defaultOptions = {
|
|||
},
|
||||
};
|
||||
|
||||
export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()("custom_events", {
|
||||
export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()({
|
||||
name: "custom_events",
|
||||
showInDocs: false,
|
||||
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const config = pluginData.config.get();
|
||||
for (const [key, event] of Object.entries(config.events)) {
|
||||
if (event.trigger.type === "command") {
|
||||
const signature = event.trigger.params ? parseSignature(event.trigger.params, commandTypes) : {};
|
||||
const eventCommand = guildCommand({
|
||||
const eventCommand = typedGuildCommand({
|
||||
trigger: event.trigger.name,
|
||||
permission: `events.${key}.trigger.can_use`,
|
||||
signature,
|
||||
|
@ -36,7 +37,7 @@ export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()(
|
|||
}
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
beforeUnload() {
|
||||
// TODO: Run clearTriggers() once we actually have something there
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { BasePluginType, globalEventListener, GlobalPluginData } from "knub";
|
||||
import { BasePluginType, typedGlobalEventListener, GlobalPluginData } from "knub";
|
||||
import * as t from "io-ts";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||
import { Guild } from "eris";
|
||||
|
@ -21,16 +21,20 @@ async function checkGuild(pluginData: GlobalPluginData<GuildAccessMonitorPluginT
|
|||
/**
|
||||
* Global plugin to monitor if Zeppelin is invited to a non-whitelisted server, and leave it
|
||||
*/
|
||||
export const GuildAccessMonitorPlugin = zeppelinGlobalPlugin<GuildAccessMonitorPluginType>()("guild_access_monitor", {
|
||||
export const GuildAccessMonitorPlugin = zeppelinGlobalPlugin<GuildAccessMonitorPluginType>()({
|
||||
name: "guild_access_monitor",
|
||||
configSchema: t.type({}),
|
||||
|
||||
events: [
|
||||
globalEventListener<GuildAccessMonitorPluginType>()("guildAvailable", ({ pluginData, args: { guild } }) => {
|
||||
checkGuild(pluginData, guild);
|
||||
typedGlobalEventListener<GuildAccessMonitorPluginType>()({
|
||||
event: "guildAvailable",
|
||||
listener({ pluginData, args: { guild } }) {
|
||||
checkGuild(pluginData, guild);
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
pluginData.state.allowedGuilds = new AllowedGuilds();
|
||||
|
||||
for (const guild of pluginData.client.guilds.values()) {
|
||||
|
|
|
@ -4,23 +4,21 @@ import { Configs } from "../../data/Configs";
|
|||
import { reloadChangedGuilds } from "./functions/reloadChangedGuilds";
|
||||
import * as t from "io-ts";
|
||||
|
||||
export const GuildConfigReloaderPlugin = zeppelinGlobalPlugin<GuildConfigReloaderPluginType>()(
|
||||
"guild_config_reloader",
|
||||
{
|
||||
showInDocs: false,
|
||||
export const GuildConfigReloaderPlugin = zeppelinGlobalPlugin<GuildConfigReloaderPluginType>()({
|
||||
name: "guild_config_reloader",
|
||||
showInDocs: false,
|
||||
|
||||
configSchema: t.type({}),
|
||||
configSchema: t.type({}),
|
||||
|
||||
async onLoad(pluginData) {
|
||||
pluginData.state.guildConfigs = new Configs();
|
||||
pluginData.state.highestConfigId = await pluginData.state.guildConfigs.getHighestId();
|
||||
async afterLoad(pluginData) {
|
||||
pluginData.state.guildConfigs = new Configs();
|
||||
pluginData.state.highestConfigId = await pluginData.state.guildConfigs.getHighestId();
|
||||
|
||||
reloadChangedGuilds(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.nextCheckTimeout);
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
reloadChangedGuilds(pluginData);
|
||||
},
|
||||
);
|
||||
|
||||
beforeUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.nextCheckTimeout);
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,12 +5,13 @@ import { GuildInfoSaverPluginType } from "./types";
|
|||
import { MINUTES } from "../../utils";
|
||||
import * as t from "io-ts";
|
||||
|
||||
export const GuildInfoSaverPlugin = zeppelinGuildPlugin<GuildInfoSaverPluginType>()("guild_info_saver", {
|
||||
export const GuildInfoSaverPlugin = zeppelinGuildPlugin<GuildInfoSaverPluginType>()({
|
||||
name: "guild_info_saver",
|
||||
showInDocs: false,
|
||||
|
||||
configSchema: t.type({}),
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.allowedGuilds = new AllowedGuilds();
|
||||
|
|
|
@ -28,7 +28,8 @@ const defaultOptions: PluginOptions<LocateUserPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()("locate_user", {
|
||||
export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()({
|
||||
name: "locate_user",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Locate user",
|
||||
|
@ -58,7 +59,7 @@ export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()("loc
|
|||
GuildBanRemoveAlertsEvt
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.alerts = GuildVCAlerts.getGuildInstance(guild.id);
|
||||
|
@ -70,7 +71,7 @@ export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()("loc
|
|||
fillActiveAlertsList(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.outdatedAlertsTimeout as Timeout);
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildVCAlerts } from "../../data/GuildVCAlerts";
|
||||
import Timeout = NodeJS.Timeout;
|
||||
|
||||
|
@ -19,5 +19,5 @@ export interface LocateUserPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const locateUserCmd = guildCommand<LocateUserPluginType>();
|
||||
export const locateUserEvt = guildEventListener<LocateUserPluginType>();
|
||||
export const locateUserCmd = typedGuildCommand<LocateUserPluginType>();
|
||||
export const locateUserEvt = typedGuildEventListener<LocateUserPluginType>();
|
||||
|
|
|
@ -47,7 +47,8 @@ const defaultOptions: PluginOptions<LogsPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()("logs", {
|
||||
export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()({
|
||||
name: "logs",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Logs",
|
||||
|
@ -84,7 +85,7 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()("logs", {
|
|||
},
|
||||
},
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.guildLogs = new GuildLogs(guild.id);
|
||||
|
@ -122,7 +123,7 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()("logs", {
|
|||
state.regexRunner.on("repeatedTimeout", state.regexRunnerRepeatedTimeoutListener);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
pluginData.state.guildLogs.removeListener("log", pluginData.state.logListener);
|
||||
|
||||
pluginData.state.savedMessages.events.off("delete", pluginData.state.onMessageDeleteFn);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildEventListener } from "knub";
|
||||
import { TRegex } from "../../validatorUtils";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
|
@ -72,4 +72,4 @@ export interface LogsPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const logsEvt = guildEventListener<LogsPluginType>();
|
||||
export const logsEvt = typedGuildEventListener<LogsPluginType>();
|
||||
|
|
|
@ -59,7 +59,7 @@ export async function getLogMessage(
|
|||
member = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
}
|
||||
|
||||
const memberConfig = pluginData.config.getMatchingConfig({ member, userId: user.id }) || ({} as any);
|
||||
const memberConfig = (await pluginData.config.getMatchingConfig({ member, userId: user.id })) || ({} as any);
|
||||
|
||||
// Revert to old behavior (verbose name w/o ping if allow_user_mentions is enabled (for whatever reason))
|
||||
if (config.allow_user_mentions) {
|
||||
|
|
|
@ -20,7 +20,8 @@ const defaultOptions: PluginOptions<MessageSaverPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const MessageSaverPlugin = zeppelinGuildPlugin<MessageSaverPluginType>()("message_saver", {
|
||||
export const MessageSaverPlugin = zeppelinGuildPlugin<MessageSaverPluginType>()({
|
||||
name: "message_saver",
|
||||
showInDocs: false,
|
||||
|
||||
configSchema: ConfigSchema,
|
||||
|
@ -40,7 +41,7 @@ export const MessageSaverPlugin = zeppelinGuildPlugin<MessageSaverPluginType>()(
|
|||
MessageDeleteBulkEvt,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
|
@ -14,5 +14,5 @@ export interface MessageSaverPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const messageSaverCmd = guildCommand<MessageSaverPluginType>();
|
||||
export const messageSaverEvt = guildEventListener<MessageSaverPluginType>();
|
||||
export const messageSaverCmd = typedGuildCommand<MessageSaverPluginType>();
|
||||
export const messageSaverEvt = typedGuildEventListener<MessageSaverPluginType>();
|
||||
|
|
|
@ -110,7 +110,8 @@ const defaultOptions = {
|
|||
],
|
||||
};
|
||||
|
||||
export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()("mod_actions", {
|
||||
export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()({
|
||||
name: "mod_actions",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Mod actions",
|
||||
|
@ -187,7 +188,7 @@ export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()("mod
|
|||
},
|
||||
},
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.mutes = GuildMutes.getGuildInstance(guild.id);
|
||||
|
@ -207,7 +208,7 @@ export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()("mod
|
|||
outdatedTempbansLoop(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
pluginData.state.unloaded = true;
|
||||
pluginData.state.events.removeAllListeners();
|
||||
},
|
||||
|
|
|
@ -44,7 +44,7 @@ export const AddCaseCmd = modActionsCmd({
|
|||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData, "can_act_as_other", { message: msg })) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ export const BanCmd = modActionsCmd({
|
|||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id })) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id }))) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
@ -160,7 +160,8 @@ export const BanCmd = modActionsCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const deleteMessageDays = args["delete-days"] ?? pluginData.config.getForMessage(msg).ban_delete_message_days;
|
||||
const deleteMessageDays =
|
||||
args["delete-days"] ?? (await pluginData.config.getForMessage(msg)).ban_delete_message_days;
|
||||
const banResult = await banUserId(
|
||||
pluginData,
|
||||
user.id,
|
||||
|
|
|
@ -53,7 +53,7 @@ export const ForcebanCmd = modActionsCmd({
|
|||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData, "can_act_as_other", { message: msg })) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ export const UnbanCmd = modActionsCmd({
|
|||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id })) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id }))) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export const WarnCmd = modActionsCmd({
|
|||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData, "can_act_as_other", { message: msg })) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
msg.channel.createMessage(errorMessage("You don't have permission to use -mod"));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ import { Case } from "../../../data/entities/Case";
|
|||
* Create a BAN case automatically when a user is banned manually.
|
||||
* Attempts to find the ban's details in the audit log.
|
||||
*/
|
||||
export const CreateBanCaseOnManualBanEvt = modActionsEvt(
|
||||
"guildBanAdd",
|
||||
async ({ pluginData, args: { guild, user } }) => {
|
||||
export const CreateBanCaseOnManualBanEvt = modActionsEvt({
|
||||
event: "guildBanAdd",
|
||||
async listener({ pluginData, args: { guild, user } }) {
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Ban, user.id)) {
|
||||
clearIgnoredEvents(pluginData, IgnoredEventType.Ban, user.id);
|
||||
return;
|
||||
|
@ -39,7 +39,7 @@ export const CreateBanCaseOnManualBanEvt = modActionsEvt(
|
|||
|
||||
mod = await resolveUser(pluginData.client, modId);
|
||||
|
||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : pluginData.config.getForUser(mod);
|
||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : await pluginData.config.getForUser(mod);
|
||||
|
||||
if (config.create_cases_for_manual_actions) {
|
||||
reason = relevantAuditLogEntry.reason || "";
|
||||
|
@ -72,4 +72,4 @@ export const CreateBanCaseOnManualBanEvt = modActionsEvt(
|
|||
|
||||
pluginData.state.events.emit("ban", user.id, reason);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -14,9 +14,9 @@ import { Case } from "../../../data/entities/Case";
|
|||
* Create a KICK case automatically when a user is kicked manually.
|
||||
* Attempts to find the kick's details in the audit log.
|
||||
*/
|
||||
export const CreateKickCaseOnManualKickEvt = modActionsEvt(
|
||||
"guildMemberRemove",
|
||||
async ({ pluginData, args: { member } }) => {
|
||||
export const CreateKickCaseOnManualKickEvt = modActionsEvt({
|
||||
event: "guildMemberRemove",
|
||||
async listener({ pluginData, args: { member } }) {
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Kick, member.id)) {
|
||||
clearIgnoredEvents(pluginData, IgnoredEventType.Kick, member.id);
|
||||
return;
|
||||
|
@ -42,7 +42,7 @@ export const CreateKickCaseOnManualKickEvt = modActionsEvt(
|
|||
} else {
|
||||
mod = await resolveUser(pluginData.client, kickAuditLogEntry.user.id);
|
||||
|
||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : pluginData.config.getForUser(mod);
|
||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : await pluginData.config.getForUser(mod);
|
||||
|
||||
if (config.create_cases_for_manual_actions) {
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
|
@ -67,4 +67,4 @@ export const CreateKickCaseOnManualKickEvt = modActionsEvt(
|
|||
pluginData.state.events.emit("kick", member.id, kickAuditLogEntry.reason || undefined);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -13,9 +13,9 @@ import { Case } from "../../../data/entities/Case";
|
|||
* Create an UNBAN case automatically when a user is unbanned manually.
|
||||
* Attempts to find the unban's details in the audit log.
|
||||
*/
|
||||
export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt(
|
||||
"guildBanRemove",
|
||||
async ({ pluginData, args: { guild, user } }) => {
|
||||
export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt({
|
||||
event: "guildBanRemove",
|
||||
async listener({ pluginData, args: { guild, user } }) {
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Unban, user.id)) {
|
||||
clearIgnoredEvents(pluginData, IgnoredEventType.Unban, user.id);
|
||||
return;
|
||||
|
@ -38,7 +38,7 @@ export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt(
|
|||
|
||||
mod = await resolveUser(pluginData.client, modId);
|
||||
|
||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : pluginData.config.getForUser(mod);
|
||||
const config = mod instanceof UnknownUser ? pluginData.config.get() : await pluginData.config.getForUser(mod);
|
||||
|
||||
if (config.create_cases_for_manual_actions) {
|
||||
createdCase = await casesPlugin.createCase({
|
||||
|
@ -69,4 +69,4 @@ export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt(
|
|||
|
||||
pluginData.state.events.emit("unban", user.id);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -8,9 +8,9 @@ import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
|
|||
/**
|
||||
* Show an alert if a member with prior notes joins the server
|
||||
*/
|
||||
export const PostAlertOnMemberJoinEvt = modActionsEvt(
|
||||
"guildMemberAdd",
|
||||
async ({ pluginData, args: { guild, member } }) => {
|
||||
export const PostAlertOnMemberJoinEvt = modActionsEvt({
|
||||
event: "guildMemberAdd",
|
||||
async listener({ pluginData, args: { guild, member } }) {
|
||||
const config = pluginData.config.get();
|
||||
|
||||
if (!config.alert_on_rejoin) return;
|
||||
|
@ -51,4 +51,4 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt(
|
|||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@ export async function actualKickMemberCmd(
|
|||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData.config.getForMessage(msg), "can_act_as_other")) {
|
||||
if (!(await hasPermission(await pluginData.config.getForMessage(msg), "can_act_as_other"))) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Member, Message, TextChannel, User } from "eris";
|
||||
import { GuildTextableChannel, Member, Message, TextChannel, User } from "eris";
|
||||
import { asSingleLine, isDiscordRESTError, UnknownUser } from "../../../utils";
|
||||
import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { GuildPluginData } from "knub";
|
||||
|
@ -10,7 +10,6 @@ import { MutesPlugin } from "../../Mutes/MutesPlugin";
|
|||
import { readContactMethodsFromArgs } from "./readContactMethodsFromArgs";
|
||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
||||
import { logger } from "../../../logger";
|
||||
import { GuildMessage } from "knub/dist/helpers";
|
||||
|
||||
/**
|
||||
* The actual function run by both !mute and !forcemute.
|
||||
|
@ -19,7 +18,7 @@ import { GuildMessage } from "knub/dist/helpers";
|
|||
export async function actualMuteUserCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
user: User | UnknownUser,
|
||||
msg: GuildMessage,
|
||||
msg: Message<GuildTextableChannel>,
|
||||
args: { time?: number; reason?: string; mod: Member; notify?: string; "notify-channel"?: TextChannel },
|
||||
) {
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
|
@ -27,7 +26,7 @@ export async function actualMuteUserCmd(
|
|||
let pp: User | null = null;
|
||||
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData, "can_act_as_other", { message: msg })) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export async function actualUnmuteCmd(
|
|||
let pp: User | null = null;
|
||||
|
||||
if (args.mod) {
|
||||
if (!hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id })) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id }))) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { tNullable, UserNotificationMethod, UserNotificationResult } from "../../utils";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildMutes } from "../../data/GuildMutes";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
|
@ -148,5 +148,5 @@ export interface BanOptions {
|
|||
|
||||
export type ModActionType = "note" | "warn" | "mute" | "unmute" | "kick" | "ban" | "unban";
|
||||
|
||||
export const modActionsCmd = guildCommand<ModActionsPluginType>();
|
||||
export const modActionsEvt = guildEventListener<ModActionsPluginType>();
|
||||
export const modActionsCmd = typedGuildCommand<ModActionsPluginType>();
|
||||
export const modActionsEvt = typedGuildEventListener<ModActionsPluginType>();
|
||||
|
|
|
@ -61,7 +61,8 @@ const EXPIRED_MUTE_CHECK_INTERVAL = 60 * 1000;
|
|||
let FIRST_CHECK_TIME = Date.now();
|
||||
const FIRST_CHECK_INCREMENT = 5 * 1000;
|
||||
|
||||
export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()("mutes", {
|
||||
export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
||||
name: "mutes",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Mutes",
|
||||
|
@ -104,7 +105,7 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()("mutes", {
|
|||
},
|
||||
},
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
pluginData.state.mutes = GuildMutes.getGuildInstance(pluginData.guild.id);
|
||||
pluginData.state.cases = GuildCases.getGuildInstance(pluginData.guild.id);
|
||||
pluginData.state.serverLogs = new GuildLogs(pluginData.guild.id);
|
||||
|
@ -125,7 +126,7 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()("mutes", {
|
|||
}, firstCheckTime - Date.now());
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
clearInterval(pluginData.state.muteClearIntervalId);
|
||||
pluginData.state.events.removeAllListeners();
|
||||
},
|
||||
|
|
|
@ -3,9 +3,12 @@ import { mutesEvt } from "../types";
|
|||
/**
|
||||
* Clear active mute from the member if the member is banned
|
||||
*/
|
||||
export const ClearActiveMuteOnMemberBanEvt = mutesEvt("guildBanAdd", async ({ pluginData, args: { user } }) => {
|
||||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(user.id);
|
||||
if (mute) {
|
||||
pluginData.state.mutes.clear(user.id);
|
||||
}
|
||||
export const ClearActiveMuteOnMemberBanEvt = mutesEvt({
|
||||
event: "guildBanAdd",
|
||||
async listener({ pluginData, args: { user } }) {
|
||||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(user.id);
|
||||
if (mute) {
|
||||
pluginData.state.mutes.clear(user.id);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,9 +4,9 @@ import { memberHasMutedRole } from "../functions/memberHasMutedRole";
|
|||
/**
|
||||
* Clear active mute if the mute role is removed manually
|
||||
*/
|
||||
export const ClearActiveMuteOnRoleRemovalEvt = mutesEvt(
|
||||
"guildMemberUpdate",
|
||||
async ({ pluginData, args: { member } }) => {
|
||||
export const ClearActiveMuteOnRoleRemovalEvt = mutesEvt({
|
||||
event: "guildMemberUpdate",
|
||||
async listener({ pluginData, args: { member } }) {
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
if (!muteRole) return;
|
||||
|
||||
|
@ -17,4 +17,4 @@ export const ClearActiveMuteOnRoleRemovalEvt = mutesEvt(
|
|||
await pluginData.state.mutes.clear(muteRole);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -6,19 +6,22 @@ import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
|||
/**
|
||||
* Reapply active mutes on join
|
||||
*/
|
||||
export const ReapplyActiveMuteOnJoinEvt = mutesEvt("guildMemberAdd", async ({ pluginData, args: { member } }) => {
|
||||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id);
|
||||
if (mute) {
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
export const ReapplyActiveMuteOnJoinEvt = mutesEvt({
|
||||
event: "guildMemberAdd",
|
||||
async listener({ pluginData, args: { member } }) {
|
||||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(member.id);
|
||||
if (mute) {
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
|
||||
if (muteRole) {
|
||||
const memberRoleLock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||
await member.addRole(muteRole);
|
||||
memberRoleLock.unlock();
|
||||
if (muteRole) {
|
||||
const memberRoleLock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||
await member.addRole(muteRole);
|
||||
memberRoleLock.unlock();
|
||||
}
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_MUTE_REJOIN, {
|
||||
member: stripObjectToScalars(member, ["user", "roles"]),
|
||||
});
|
||||
}
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_MUTE_REJOIN, {
|
||||
member: stripObjectToScalars(member, ["user", "roles"]),
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -52,7 +52,7 @@ export async function muteUser(
|
|||
}
|
||||
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, user.id, true); // Grab the fresh member so we don't have stale role info
|
||||
const config = pluginData.config.getMatchingConfig({ member, userId });
|
||||
const config = await pluginData.config.getMatchingConfig({ member, userId });
|
||||
|
||||
let rolesToRestore: string[] = [];
|
||||
if (member) {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { tNullable, UserNotificationMethod, UserNotificationResult } from "../..
|
|||
import { Mute } from "../../data/entities/Mute";
|
||||
import { Member } from "eris";
|
||||
import { Case } from "../../data/entities/Case";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
|
@ -78,5 +78,5 @@ export interface MuteOptions {
|
|||
isAutomodAction?: boolean;
|
||||
}
|
||||
|
||||
export const mutesCmd = guildCommand<MutesPluginType>();
|
||||
export const mutesEvt = guildEventListener<MutesPluginType>();
|
||||
export const mutesCmd = typedGuildCommand<MutesPluginType>();
|
||||
export const mutesEvt = typedGuildEventListener<MutesPluginType>();
|
||||
|
|
|
@ -21,7 +21,8 @@ const defaultOptions: PluginOptions<NameHistoryPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()("name_history", {
|
||||
export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
|
||||
name: "name_history",
|
||||
showInDocs: false,
|
||||
|
||||
configSchema: ConfigSchema,
|
||||
|
@ -38,7 +39,7 @@ export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()("n
|
|||
MessageCreateEvt,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.nicknameHistory = GuildNicknameHistory.getGuildInstance(guild.id);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
|
||||
import { UsernameHistory } from "../../data/UsernameHistory";
|
||||
import { Queue } from "../../Queue";
|
||||
|
@ -18,5 +18,5 @@ export interface NameHistoryPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const nameHistoryCmd = guildCommand<NameHistoryPluginType>();
|
||||
export const nameHistoryEvt = guildEventListener<NameHistoryPluginType>();
|
||||
export const nameHistoryCmd = typedGuildCommand<NameHistoryPluginType>();
|
||||
export const nameHistoryEvt = typedGuildEventListener<NameHistoryPluginType>();
|
||||
|
|
|
@ -16,7 +16,8 @@ const defaultOptions: PluginOptions<PersistPluginType> = {
|
|||
},
|
||||
};
|
||||
|
||||
export const PersistPlugin = zeppelinGuildPlugin<PersistPluginType>()("persist", {
|
||||
export const PersistPlugin = zeppelinGuildPlugin<PersistPluginType>()({
|
||||
name: "persist",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Persist",
|
||||
|
@ -36,7 +37,7 @@ export const PersistPlugin = zeppelinGuildPlugin<PersistPluginType>()("persist",
|
|||
LoadDataEvt,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.persistedData = GuildPersistedData.getGuildInstance(guild.id);
|
||||
|
|
|
@ -27,12 +27,12 @@ export const LoadDataEvt = persistEvt({
|
|||
}
|
||||
|
||||
const toRestore: MemberOptions = {};
|
||||
const config = pluginData.config.getForMember(member);
|
||||
const config = await pluginData.config.getForMember(member);
|
||||
const restoredData: string[] = [];
|
||||
|
||||
// Check permissions
|
||||
const me = pluginData.guild.members.get(pluginData.client.user.id)!;
|
||||
let requiredPermissions = 0;
|
||||
let requiredPermissions = 0n;
|
||||
if (config.persist_nicknames) requiredPermissions |= p.manageNicknames;
|
||||
if (config.persisted_roles) requiredPermissions |= p.manageRoles;
|
||||
const missingPermissions = getMissingPermissions(me.permission, requiredPermissions);
|
||||
|
|
|
@ -12,7 +12,7 @@ export const StoreDataEvt = persistEvt({
|
|||
|
||||
let persist = false;
|
||||
const persistData: IPartialPersistData = {};
|
||||
const config = pluginData.config.getForUser(member.user);
|
||||
const config = await pluginData.config.getForUser(member.user);
|
||||
|
||||
const persistedRoles = config.persisted_roles;
|
||||
if (persistedRoles.length && member.roles) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildEventListener } from "knub";
|
||||
import { GuildPersistedData } from "../../data/GuildPersistedData";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
|
||||
|
@ -19,4 +19,4 @@ export interface PersistPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const persistEvt = guildEventListener<PersistPluginType>();
|
||||
export const persistEvt = typedGuildEventListener<PersistPluginType>();
|
||||
|
|
|
@ -20,7 +20,8 @@ const defaultOptions: PluginOptions<PingableRolesPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const PingableRolesPlugin = zeppelinGuildPlugin<PingableRolesPluginType>()("pingable_roles", {
|
||||
export const PingableRolesPlugin = zeppelinGuildPlugin<PingableRolesPluginType>()({
|
||||
name: "pingable_roles",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Pingable roles",
|
||||
|
@ -41,7 +42,7 @@ export const PingableRolesPlugin = zeppelinGuildPlugin<PingableRolesPluginType>(
|
|||
MessageCreateDisablePingableEvt,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.pingableRoles = GuildPingableRoles.getGuildInstance(guild.id);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
|
||||
import { GuildPingableRoles } from "../../data/GuildPingableRoles";
|
||||
import { PingableRole } from "../../data/entities/PingableRole";
|
||||
|
||||
|
@ -18,5 +18,5 @@ export interface PingableRolesPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const pingableRolesCmd = guildCommand<PingableRolesPluginType>();
|
||||
export const pingableRolesEvt = guildEventListener<PingableRolesPluginType>();
|
||||
export const pingableRolesCmd = typedGuildCommand<PingableRolesPluginType>();
|
||||
export const pingableRolesEvt = typedGuildEventListener<PingableRolesPluginType>();
|
||||
|
|
|
@ -28,7 +28,8 @@ const defaultOptions: PluginOptions<PostPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const PostPlugin = zeppelinGuildPlugin<PostPluginType>()("post", {
|
||||
export const PostPlugin = zeppelinGuildPlugin<PostPluginType>()({
|
||||
name: "post",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Post",
|
||||
|
@ -49,7 +50,7 @@ export const PostPlugin = zeppelinGuildPlugin<PostPluginType>()("post", {
|
|||
ScheduledPostsDeleteCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||
|
@ -59,7 +60,7 @@ export const PostPlugin = zeppelinGuildPlugin<PostPluginType>()("post", {
|
|||
scheduledPostLoop(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.scheduledPostLoopTimeout);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand } from "knub";
|
||||
import { BasePluginType, typedGuildCommand } from "knub";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildScheduledPosts } from "../../data/GuildScheduledPosts";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
|
@ -20,4 +20,4 @@ export interface PostPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const postCmd = guildCommand<PostPluginType>();
|
||||
export const postCmd = typedGuildCommand<PostPluginType>();
|
||||
|
|
|
@ -31,7 +31,8 @@ const defaultOptions: PluginOptions<ReactionRolesPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const ReactionRolesPlugin = zeppelinGuildPlugin<ReactionRolesPluginType>()("reaction_roles", {
|
||||
export const ReactionRolesPlugin = zeppelinGuildPlugin<ReactionRolesPluginType>()({
|
||||
name: "reaction_roles",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Reaction roles",
|
||||
|
@ -53,7 +54,7 @@ export const ReactionRolesPlugin = zeppelinGuildPlugin<ReactionRolesPluginType>(
|
|||
AddReactionRoleEvt,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.reactionRoles = GuildReactionRoles.getGuildInstance(guild.id);
|
||||
|
@ -70,7 +71,7 @@ export const ReactionRolesPlugin = zeppelinGuildPlugin<ReactionRolesPluginType>(
|
|||
}
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
if (pluginData.state.autoRefreshTimeout) {
|
||||
clearTimeout(pluginData.state.autoRefreshTimeout);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ export const AddReactionRoleEvt = reactionRolesEvt({
|
|||
}
|
||||
|
||||
// Remove the reaction after a small delay
|
||||
const config = pluginData.config.getForMember(member);
|
||||
const config = await pluginData.config.getForMember(member);
|
||||
if (config.remove_user_reactions) {
|
||||
setTimeout(() => {
|
||||
pluginData.state.reactionRemoveQueue.add(async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildEventListener, guildCommand } from "knub";
|
||||
import { BasePluginType, typedGuildEventListener, typedGuildCommand } from "knub";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildReactionRoles } from "../../data/GuildReactionRoles";
|
||||
import { Queue } from "../../Queue";
|
||||
|
@ -41,5 +41,5 @@ export interface ReactionRolesPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const reactionRolesCmd = guildCommand<ReactionRolesPluginType>();
|
||||
export const reactionRolesEvt = guildEventListener<ReactionRolesPluginType>();
|
||||
export const reactionRolesCmd = typedGuildCommand<ReactionRolesPluginType>();
|
||||
export const reactionRolesEvt = typedGuildEventListener<ReactionRolesPluginType>();
|
||||
|
|
|
@ -22,7 +22,8 @@ const defaultOptions: PluginOptions<RemindersPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()("reminders", {
|
||||
export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()({
|
||||
name: "reminders",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Reminders",
|
||||
|
@ -39,7 +40,7 @@ export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()("remin
|
|||
RemindersDeleteCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.reminders = GuildReminders.getGuildInstance(guild.id);
|
||||
|
@ -50,7 +51,7 @@ export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()("remin
|
|||
postDueRemindersLoop(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
beforeUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.postRemindersTimeout);
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand } from "knub";
|
||||
import { BasePluginType, typedGuildCommand } from "knub";
|
||||
import { GuildReminders } from "../../data/GuildReminders";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
|
@ -19,4 +19,4 @@ export interface RemindersPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const remindersCmd = guildCommand<RemindersPluginType>();
|
||||
export const remindersCmd = typedGuildCommand<RemindersPluginType>();
|
||||
|
|
|
@ -30,7 +30,8 @@ const defaultOptions: PluginOptions<RolesPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const RolesPlugin = zeppelinGuildPlugin<RolesPluginType>()("roles", {
|
||||
export const RolesPlugin = zeppelinGuildPlugin<RolesPluginType>()({
|
||||
name: "roles",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Roles",
|
||||
|
@ -50,7 +51,7 @@ export const RolesPlugin = zeppelinGuildPlugin<RolesPluginType>()("roles", {
|
|||
MassRemoveRoleCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.logs = new GuildLogs(guild.id);
|
||||
|
|
|
@ -27,7 +27,7 @@ export const AddRoleCmd = rolesCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const config = pluginData.config.getForMessage(msg);
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
return;
|
||||
|
|
|
@ -43,7 +43,7 @@ export const MassAddRoleCmd = rolesCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const config = pluginData.config.getForMessage(msg);
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot assign that role");
|
||||
return;
|
||||
|
|
|
@ -43,7 +43,7 @@ export const MassRemoveRoleCmd = rolesCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const config = pluginData.config.getForMessage(msg);
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
|
||||
return;
|
||||
|
|
|
@ -27,7 +27,7 @@ export const RemoveRoleCmd = rolesCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const config = pluginData.config.getForMessage(msg);
|
||||
const config = await pluginData.config.getForMessage(msg);
|
||||
if (!config.assignable_roles.includes(roleId)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You cannot remove that role");
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand } from "knub";
|
||||
import { BasePluginType, typedGuildCommand } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
|
@ -16,4 +16,4 @@ export interface RolesPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const rolesCmd = guildCommand<RolesPluginType>();
|
||||
export const rolesCmd = typedGuildCommand<RolesPluginType>();
|
||||
|
|
|
@ -13,7 +13,8 @@ const defaultOptions: PluginOptions<SelfGrantableRolesPluginType> = {
|
|||
},
|
||||
};
|
||||
|
||||
export const SelfGrantableRolesPlugin = zeppelinGuildPlugin<SelfGrantableRolesPluginType>()("self_grantable_roles", {
|
||||
export const SelfGrantableRolesPlugin = zeppelinGuildPlugin<SelfGrantableRolesPluginType>()({
|
||||
name: "self_grantable_roles",
|
||||
showInDocs: true,
|
||||
|
||||
configSchema: ConfigSchema,
|
||||
|
@ -93,7 +94,7 @@ export const SelfGrantableRolesPlugin = zeppelinGuildPlugin<SelfGrantableRolesPl
|
|||
RoleAddCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
pluginData.state.cooldowns = new CooldownManager();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
|||
async run({ message: msg, args, pluginData }) {
|
||||
const lock = await pluginData.locks.acquire(memberRolesLock(msg.author));
|
||||
|
||||
const applyingEntries = getApplyingEntries(pluginData, msg);
|
||||
const applyingEntries = await getApplyingEntries(pluginData, msg);
|
||||
if (applyingEntries.length === 0) {
|
||||
lock.unlock();
|
||||
return;
|
||||
|
|
|
@ -7,7 +7,7 @@ export const RoleHelpCmd = selfGrantableRolesCmd({
|
|||
permission: null,
|
||||
|
||||
async run({ message: msg, pluginData }) {
|
||||
const applyingEntries = getApplyingEntries(pluginData, msg);
|
||||
const applyingEntries = await getApplyingEntries(pluginData, msg);
|
||||
if (applyingEntries.length === 0) return;
|
||||
|
||||
const allPrimaryAliases: string[] = [];
|
||||
|
|
|
@ -18,7 +18,7 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
|
|||
async run({ message: msg, args, pluginData }) {
|
||||
const lock = await pluginData.locks.acquire(memberRolesLock(msg.author));
|
||||
|
||||
const applyingEntries = getApplyingEntries(pluginData, msg);
|
||||
const applyingEntries = await getApplyingEntries(pluginData, msg);
|
||||
if (applyingEntries.length === 0) {
|
||||
lock.unlock();
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildCommand, CooldownManager } from "knub";
|
||||
import { BasePluginType, typedGuildCommand, CooldownManager } from "knub";
|
||||
|
||||
const RoleMap = t.record(t.string, t.array(t.string));
|
||||
|
||||
|
@ -31,4 +31,4 @@ export interface SelfGrantableRolesPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const selfGrantableRolesCmd = guildCommand<SelfGrantableRolesPluginType>();
|
||||
export const selfGrantableRolesCmd = typedGuildCommand<SelfGrantableRolesPluginType>();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue