3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-14 21:31:50 +00:00

Update to new Knub 30 beta. Code clean-up.

This commit is contained in:
Dragory 2020-10-01 01:43:38 +03:00
parent 5d579446c5
commit 2f470dc37a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
299 changed files with 1075 additions and 1004 deletions

View file

@ -1010,6 +1010,7 @@
"requires": {
"anymatch": "~3.1.1",
"braces": "~3.0.2",
"fsevents": "~2.1.2",
"glob-parent": "~5.1.0",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
@ -1841,6 +1842,13 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz",
"integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==",
"dev": true,
"optional": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@ -2364,19 +2372,12 @@
}
},
"knub": {
"version": "30.0.0-beta.21",
"resolved": "https://registry.npmjs.org/knub/-/knub-30.0.0-beta.21.tgz",
"integrity": "sha512-BkMLgqqw7AroarZpsQ0wK93Yk2cFBRJa8GmFPYogiXEDTA/47oQ+A21SpbRCfZ2sCxFdjdZPUZIPqgjG38H7YQ==",
"version": "30.0.0-beta.23",
"resolved": "https://registry.npmjs.org/knub/-/knub-30.0.0-beta.23.tgz",
"integrity": "sha512-kBlQQAc6IPqyVA832wR567qUdE2EZIJUGTgUQE8NGmx7MxQrqZ7yvK1+Mkzh3HlNBgnrAgMorRimQHeO+xEXxw==",
"requires": {
"knub-command-manager": "^8.1.2",
"ts-essentials": "^6.0.7"
},
"dependencies": {
"escape-string-regexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
"integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w=="
}
}
},
"knub-command-manager": {

View file

@ -38,7 +38,7 @@
"humanize-duration": "^3.15.0",
"io-ts": "^2.0.0",
"js-yaml": "^3.13.1",
"knub": "^30.0.0-beta.21",
"knub": "^30.0.0-beta.23",
"knub-command-manager": "^8.1.2",
"last-commit-log": "^2.1.0",
"lodash.chunk": "^4.2.0",

View file

@ -3,27 +3,20 @@
*/
import { Member } from "eris";
import {
CommandContext,
configUtils,
ConfigValidationError,
helpers,
PluginBlueprint,
PluginData,
PluginOptions,
} from "knub";
import { CommandContext, configUtils, ConfigValidationError, GuildPluginData, helpers, PluginOptions } from "knub";
import { decodeAndValidateStrict, StrictValidationError, validate } from "./validatorUtils";
import { deepKeyIntersect, errorMessage, successMessage, tDeepPartial, tNullable } from "./utils";
import { ZeppelinPluginBlueprint } from "./plugins/ZeppelinPluginBlueprint";
import { TZeppelinKnub } from "./types";
import { ExtendedMatchParams } from "knub/dist/config/PluginConfigManager"; // TODO: Export from Knub index
import * as t from "io-ts";
import { PluginOverrideCriteria } from "knub/dist/config/configTypes";
import { Tail } from "./utils/typeUtils";
import { AnyPluginData } from "knub/dist/plugins/PluginData";
import { ZeppelinPlugin } from "./plugins/ZeppelinPlugin";
const { getMemberLevel } = helpers;
export function canActOn(pluginData: PluginData<any>, member1: Member, member2: Member, allowSameLevel = false) {
export function canActOn(pluginData: GuildPluginData<any>, member1: Member, member2: Member, allowSameLevel = false) {
if (member2.id === pluginData.client.user.id) {
return false;
}
@ -33,7 +26,7 @@ export function canActOn(pluginData: PluginData<any>, member1: Member, member2:
return allowSameLevel ? ourLevel >= memberLevel : ourLevel > memberLevel;
}
export function hasPermission(pluginData: PluginData<any>, permission: string, matchParams: ExtendedMatchParams) {
export function hasPermission(pluginData: AnyPluginData<any>, permission: string, matchParams: ExtendedMatchParams) {
const config = pluginData.config.getMatchingConfig(matchParams);
return helpers.hasPermission(config, permission);
}
@ -71,8 +64,8 @@ export function strictValidationErrorToConfigValidationError(err: StrictValidati
}
export function getPluginConfigPreprocessor(
blueprint: ZeppelinPluginBlueprint,
customPreprocessor?: PluginBlueprint<any>["configPreprocessor"],
blueprint: ZeppelinPlugin,
customPreprocessor?: ZeppelinPlugin["configPreprocessor"],
) {
return async (options: PluginOptions<any>) => {
// 1. Validate the basic structure of plugin config
@ -141,22 +134,22 @@ export function getPluginConfigPreprocessor(
};
}
export function sendSuccessMessage(pluginData: PluginData<any>, channel, body) {
const emoji = pluginData.guildConfig.success_emoji || undefined;
export function sendSuccessMessage(pluginData: AnyPluginData<any>, channel, body) {
const emoji = pluginData.fullConfig.success_emoji || undefined;
return channel.createMessage(successMessage(body, emoji));
}
export function sendErrorMessage(pluginData: PluginData<any>, channel, body) {
const emoji = pluginData.guildConfig.error_emoji || undefined;
export function sendErrorMessage(pluginData: AnyPluginData<any>, channel, body) {
const emoji = pluginData.fullConfig.error_emoji || undefined;
return channel.createMessage(errorMessage(body, emoji));
}
export function getBaseUrl(pluginData: PluginData<any>) {
export function getBaseUrl(pluginData: AnyPluginData<any>) {
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
return knub.getGlobalConfig().url;
}
export function isOwner(pluginData: PluginData<any>, userId: string) {
export function isOwner(pluginData: AnyPluginData<any>, userId: string) {
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
const owners = knub.getGlobalConfig().owners;
if (!owners) {

View file

@ -1,8 +1,8 @@
import { PluginOptions } from "knub";
import { AutoDeletePluginType, ConfigSchema } from "./types";
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { GuildLogs } from "src/data/GuildLogs";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildLogs } from "../../data/GuildLogs";
import { onMessageCreate } from "./util/onMessageCreate";
import { onMessageDelete } from "./util/onMessageDelete";
import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk";
@ -15,7 +15,7 @@ const defaultOptions: PluginOptions<AutoDeletePluginType> = {
},
};
export const AutoDeletePlugin = zeppelinPlugin<AutoDeletePluginType>()("auto_delete", {
export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()("auto_delete", {
showInDocs: true,
info: {
prettyName: "Auto-delete",

View file

@ -1,9 +1,9 @@
import * as t from "io-ts";
import { BasePluginType } from "knub";
import { tDelayString, MINUTES } from "src/utils";
import { GuildLogs } from "src/data/GuildLogs";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { BasePluginType, guildCommand, guildEventListener } from "knub";
import { tDelayString, MINUTES } from "../../utils";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { SavedMessage } from "../../data/entities/SavedMessage";
export const MAX_DELAY = 5 * MINUTES;

View file

@ -1,11 +1,11 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutoDeletePluginType } from "../types";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { scheduleNextDeletion } from "./scheduleNextDeletion";
import { sorter } from "src/utils";
import { sorter } from "../../../utils";
export function addMessageToDeletionQueue(
pluginData: PluginData<AutoDeletePluginType>,
pluginData: GuildPluginData<AutoDeletePluginType>,
msg: SavedMessage,
delay: number,
) {

View file

@ -1,13 +1,13 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutoDeletePluginType } from "../types";
import moment from "moment-timezone";
import { LogType } from "src/data/LogType";
import { stripObjectToScalars, resolveUser } from "src/utils";
import { logger } from "src/logger";
import { LogType } from "../../../data/LogType";
import { stripObjectToScalars, resolveUser } from "../../../utils";
import { logger } from "../../../logger";
import { scheduleNextDeletion } from "./scheduleNextDeletion";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
export async function deleteNextItem(pluginData: PluginData<AutoDeletePluginType>) {
export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePluginType>) {
const [itemToDelete] = pluginData.state.deletionQueue.splice(0, 1);
if (!itemToDelete) return;

View file

@ -1,11 +1,11 @@
import { AutoDeletePluginType, MAX_DELAY } from "../types";
import { PluginData } from "knub";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { convertDelayStringToMS, resolveMember } from "src/utils";
import { LogType } from "src/data/LogType";
import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { convertDelayStringToMS, resolveMember } from "../../../utils";
import { LogType } from "../../../data/LogType";
import { addMessageToDeletionQueue } from "./addMessageToDeletionQueue";
export async function onMessageCreate(pluginData: PluginData<AutoDeletePluginType>, msg: SavedMessage) {
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 });
if (config.enabled) {

View file

@ -1,9 +1,9 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutoDeletePluginType } from "../types";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { scheduleNextDeletion } from "./scheduleNextDeletion";
export function onMessageDelete(pluginData: PluginData<AutoDeletePluginType>, msg: SavedMessage) {
export function onMessageDelete(pluginData: GuildPluginData<AutoDeletePluginType>, msg: SavedMessage) {
const indexToDelete = pluginData.state.deletionQueue.findIndex(item => item.message.id === msg.id);
if (indexToDelete > -1) {
pluginData.state.deletionQueue.splice(indexToDelete, 1);

View file

@ -1,9 +1,9 @@
import { AutoDeletePluginType } from "../types";
import { PluginData } from "knub";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { onMessageDelete } from "./onMessageDelete";
export function onMessageDeleteBulk(pluginData: PluginData<AutoDeletePluginType>, messages: SavedMessage[]) {
export function onMessageDeleteBulk(pluginData: GuildPluginData<AutoDeletePluginType>, messages: SavedMessage[]) {
for (const msg of messages) {
onMessageDelete(pluginData, msg);
}

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutoDeletePluginType } from "../types";
import { deleteNextItem } from "./deleteNextItem";
export function scheduleNextDeletion(pluginData: PluginData<AutoDeletePluginType>) {
export function scheduleNextDeletion(pluginData: GuildPluginData<AutoDeletePluginType>) {
if (pluginData.state.deletionQueue.length === 0) {
clearTimeout(pluginData.state.nextDeletionTimeout);
return;

View file

@ -1,10 +1,10 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { AutoReactionsPluginType, ConfigSchema } from "./types";
import { PluginOptions } from "knub";
import { NewAutoReactionsCmd } from "./commands/NewAutoReactionsCmd";
import { DisableAutoReactionsCmd } from "./commands/DisableAutoReactionsCmd";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { GuildAutoReactions } from "src/data/GuildAutoReactions";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildAutoReactions } from "../../data/GuildAutoReactions";
import { AddReactionsEvt } from "./events/AddReactionsEvt";
import { trimPluginDescription } from "../../utils";
import { LogsPlugin } from "../Logs/LogsPlugin";
@ -23,7 +23,7 @@ const defaultOptions: PluginOptions<AutoReactionsPluginType> = {
],
};
export const AutoReactionsPlugin = zeppelinPlugin<AutoReactionsPluginType>()("auto_reactions", {
export const AutoReactionsPlugin = zeppelinGuildPlugin<AutoReactionsPluginType>()("auto_reactions", {
showInDocs: true,
info: {
prettyName: "Auto-reactions",

View file

@ -1,6 +1,6 @@
import { autoReactionsCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
export const DisableAutoReactionsCmd = autoReactionsCmd({
trigger: "auto_reactions disable",

View file

@ -1,7 +1,7 @@
import { autoReactionsCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { canUseEmoji, customEmojiRegex, isEmoji } from "src/utils";
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
import { canUseEmoji, customEmojiRegex, isEmoji } from "../../../utils";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
import { Constants, GuildChannel } from "eris";
import { readChannelPermissions } from "../../../utils/readChannelPermissions";

View file

@ -1,6 +1,6 @@
import { autoReactionsEvt } from "../types";
import { isDiscordRESTError } from "src/utils";
import { LogType } from "src/data/LogType";
import { isDiscordRESTError } from "../../../utils";
import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { Constants, GuildChannel } from "eris";

View file

@ -1,8 +1,8 @@
import * as t from "io-ts";
import { BasePluginType, command, eventListener } from "knub";
import { GuildLogs } from "src/data/GuildLogs";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { GuildAutoReactions } from "src/data/GuildAutoReactions";
import { BasePluginType, guildCommand, guildEventListener } from "knub";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildAutoReactions } from "../../data/GuildAutoReactions";
export const ConfigSchema = t.type({
can_manage: t.boolean,
@ -18,5 +18,5 @@ export interface AutoReactionsPluginType extends BasePluginType {
};
}
export const autoReactionsCmd = command<AutoReactionsPluginType>();
export const autoReactionsEvt = eventListener<AutoReactionsPluginType>();
export const autoReactionsCmd = guildCommand<AutoReactionsPluginType>();
export const autoReactionsEvt = guildEventListener<AutoReactionsPluginType>();

View file

@ -1,4 +1,4 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { AutomodPluginType, ConfigSchema } from "./types";
import { RunAutomodOnJoinEvt } from "./events/RunAutomodOnJoinEvt";
import { GuildLogs } from "../../data/GuildLogs";
@ -147,7 +147,7 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
return options;
};
export const AutomodPlugin = zeppelinPlugin<AutomodPluginType>()("automod", {
export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()("automod", {
showInDocs: true,
info: pluginInfo,

View file

@ -1,9 +1,9 @@
import { command } from "knub";
import { guildCommand, GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
import { sendSuccessMessage } from "../../../pluginUtils";
export const AntiraidClearCmd = command<AutomodPluginType>()({
export const AntiraidClearCmd = guildCommand<AutomodPluginType>()({
trigger: ["antiraid clear", "antiraid reset", "antiraid none", "antiraid off"],
permission: "can_set_antiraid",

View file

@ -1,10 +1,10 @@
import { command } from "knub";
import { guildCommand, 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 = command<AutomodPluginType>()({
export const SetAntiraidCmd = guildCommand<AutomodPluginType>()({
trigger: "antiraid",
permission: "can_set_antiraid",

View file

@ -1,14 +1,14 @@
import { command } from "knub";
import { guildCommand, 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 = command<AutomodPluginType>()({
export const ViewAntiraidCmd = guildCommand<AutomodPluginType>()({
trigger: "antiraid",
permission: "can_view_antiraid",
async run({ pluginData, message, args }) {
async run({ pluginData, message }) {
if (pluginData.state.cachedAntiraidLevel) {
message.channel.createMessage(`Anti-raid is set to **${pluginData.state.cachedAntiraidLevel}**`);
} else {

View file

@ -1,9 +1,9 @@
import { eventListener } from "knub";
import { guildEventListener } from "knub";
import { AutomodContext, AutomodPluginType } from "../types";
import { runAutomod } from "../functions/runAutomod";
import { RecentActionType } from "../constants";
export const RunAutomodOnJoinEvt = eventListener<AutomodPluginType>()(
export const RunAutomodOnJoinEvt = guildEventListener<AutomodPluginType>()(
"guildMemberAdd",
({ pluginData, args: { member } }) => {
const context: AutomodContext = {

View file

@ -1,11 +1,11 @@
import { eventListener } from "knub";
import { guildEventListener } 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 = eventListener<AutomodPluginType>()(
export const RunAutomodOnMemberUpdate = guildEventListener<AutomodPluginType>()(
"guildMemberUpdate",
({ pluginData, args: { member, oldMember } }) => {
if (!oldMember) return;

View file

@ -1,12 +1,16 @@
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodContext, AutomodPluginType } from "../types";
import { runAutomod } from "../functions/runAutomod";
import { addRecentActionsFromMessage } from "../functions/addRecentActionsFromMessage";
import moment from "moment-timezone";
import { clearRecentActionsForMessage } from "../functions/clearRecentActionsForMessage";
export function runAutomodOnMessage(pluginData: PluginData<AutomodPluginType>, message: SavedMessage, isEdit: boolean) {
export function runAutomodOnMessage(
pluginData: GuildPluginData<AutomodPluginType>,
message: SavedMessage,
isEdit: boolean,
) {
const user = pluginData.client.users.get(message.user_id);
const member = pluginData.guild.members.get(message.user_id);

View file

@ -1,9 +1,9 @@
import { AutomodContext, AutomodPluginType } from "../types";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";
import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils";
export function addRecentActionsFromMessage(pluginData: PluginData<AutomodPluginType>, context: AutomodContext) {
export function addRecentActionsFromMessage(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
const globalIdentifier = context.message.user_id;
const perChannelIdentifier = `${context.message.channel_id}-${context.message.user_id}`;
const expiresAt = Date.now() + RECENT_ACTION_EXPIRY_TIME;

View file

@ -1,10 +1,10 @@
import { AutomodContext, AutomodPluginType, TRule } from "../types";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodTriggerMatchResult } from "../helpers";
import { convertDelayStringToMS } from "../../../utils";
export function checkAndUpdateCooldown(
pluginData: PluginData<AutomodPluginType>,
pluginData: GuildPluginData<AutomodPluginType>,
rule: TRule,
context: AutomodContext,
) {

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { RECENT_NICKNAME_CHANGE_EXPIRY_TIME, RECENT_SPAM_EXPIRY_TIME } from "../constants";
export function clearOldRecentNicknameChanges(pluginData: PluginData<AutomodPluginType>) {
export function clearOldRecentNicknameChanges(pluginData: GuildPluginData<AutomodPluginType>) {
const now = Date.now();
for (const [userId, { timestamp }] of pluginData.state.recentNicknameChanges) {
if (timestamp + RECENT_NICKNAME_CHANGE_EXPIRY_TIME <= now) {

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { RECENT_ACTION_EXPIRY_TIME } from "../constants";
export function clearOldRecentActions(pluginData: PluginData<AutomodPluginType>) {
export function clearOldRecentActions(pluginData: GuildPluginData<AutomodPluginType>) {
const now = Date.now();
pluginData.state.recentActions = pluginData.state.recentActions.filter(info => {
return info.context.timestamp + RECENT_ACTION_EXPIRY_TIME > now;

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { RECENT_SPAM_EXPIRY_TIME } from "../constants";
export function clearOldRecentSpam(pluginData: PluginData<AutomodPluginType>) {
export function clearOldRecentSpam(pluginData: GuildPluginData<AutomodPluginType>) {
const now = Date.now();
pluginData.state.recentSpam = pluginData.state.recentSpam.filter(spam => {
return spam.timestamp + RECENT_SPAM_EXPIRY_TIME > now;

View file

@ -1,9 +1,9 @@
import { AutomodContext, AutomodPluginType } from "../types";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";
import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils";
export function clearRecentActionsForMessage(pluginData: PluginData<AutomodPluginType>, context: AutomodContext) {
export function clearRecentActionsForMessage(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
const globalIdentifier = context.message.user_id;
const perChannelIdentifier = `${context.message.channel_id}-${context.message.user_id}`;

View file

@ -1,8 +1,12 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { RecentActionType } from "../constants";
export function findRecentSpam(pluginData: PluginData<AutomodPluginType>, type: RecentActionType, identifier?: string) {
export function findRecentSpam(
pluginData: GuildPluginData<AutomodPluginType>,
type: RecentActionType,
identifier?: string,
) {
return pluginData.state.recentSpam.find(spam => {
return spam.type === type && (!identifier || spam.identifiers.includes(identifier));
});

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import moment from "moment-timezone";
@ -6,7 +6,7 @@ import { getMatchingRecentActions } from "./getMatchingRecentActions";
import { RecentActionType } from "../constants";
export function getMatchingMessageRecentActions(
pluginData: PluginData<AutomodPluginType>,
pluginData: GuildPluginData<AutomodPluginType>,
message: SavedMessage,
type: RecentActionType,
identifier: string,

View file

@ -1,9 +1,9 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { RecentActionType } from "../constants";
export function getMatchingRecentActions(
pluginData: PluginData<AutomodPluginType>,
pluginData: GuildPluginData<AutomodPluginType>,
type: RecentActionType,
identifier: string | null,
since: number,

View file

@ -1,11 +1,11 @@
import { MatchableTextType } from "./matchMultipleTextTypesOnMessage";
import { AutomodContext, AutomodPluginType } from "../types";
import { messageSummary, verboseChannelMention } from "../../../utils";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { User } from "eris";
export function getTextMatchPartialSummary(
pluginData: PluginData<AutomodPluginType>,
pluginData: GuildPluginData<AutomodPluginType>,
type: MatchableTextType,
context: AutomodContext,
) {

View file

@ -1,10 +1,10 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { MINUTES } from "../../../utils";
const IGNORED_ROLE_CHANGE_LIFETIME = 5 * MINUTES;
function cleanupIgnoredRoleChanges(pluginData: PluginData<AutomodPluginType>) {
function cleanupIgnoredRoleChanges(pluginData: GuildPluginData<AutomodPluginType>) {
const cutoff = Date.now() - IGNORED_ROLE_CHANGE_LIFETIME;
for (const ignoredChange of pluginData.state.ignoredRoleChanges.values()) {
if (ignoredChange.timestamp < cutoff) {
@ -13,7 +13,7 @@ function cleanupIgnoredRoleChanges(pluginData: PluginData<AutomodPluginType>) {
}
}
export function ignoreRoleChange(pluginData: PluginData<AutomodPluginType>, memberId: string, roleId: string) {
export function ignoreRoleChange(pluginData: GuildPluginData<AutomodPluginType>, memberId: string, roleId: string) {
pluginData.state.ignoredRoleChanges.add({
memberId,
roleId,
@ -26,7 +26,11 @@ export function ignoreRoleChange(pluginData: PluginData<AutomodPluginType>, memb
/**
* @return Whether the role change should be ignored
*/
export function consumeIgnoredRoleChange(pluginData: PluginData<AutomodPluginType>, memberId: string, roleId: string) {
export function consumeIgnoredRoleChange(
pluginData: GuildPluginData<AutomodPluginType>,
memberId: string,
roleId: string,
) {
for (const ignoredChange of pluginData.state.ignoredRoleChanges.values()) {
if (ignoredChange.memberId === memberId && ignoredChange.roleId === roleId) {
pluginData.state.ignoredRoleChanges.delete(ignoredChange);

View file

@ -1,6 +1,6 @@
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { resolveMember } from "../../../utils";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
type TextTriggerWithMultipleMatchTypes = {
@ -20,7 +20,7 @@ type YieldedContent = [MatchableTextType, string];
* Generator function that allows iterating through matchable pieces of text of a SavedMessage
*/
export async function* matchMultipleTextTypesOnMessage(
pluginData: PluginData<AutomodPluginType>,
pluginData: GuildPluginData<AutomodPluginType>,
trigger: TextTriggerWithMultipleMatchTypes,
msg: SavedMessage,
): AsyncIterableIterator<YieldedContent> {

View file

@ -1,11 +1,11 @@
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { TextChannel } from "eris";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
export function resolveActionContactMethods(
pluginData: PluginData<AutomodPluginType>,
pluginData: GuildPluginData<AutomodPluginType>,
actionConfig: {
notify?: string;
notifyChannel?: string;

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodContext, AutomodPluginType } from "../types";
import { availableTriggers } from "../triggers/availableTriggers";
import { availableActions } from "../actions/availableActions";
@ -6,7 +6,7 @@ import { AutomodTriggerMatchResult } from "../helpers";
import { CleanAction } from "../actions/clean";
import { checkAndUpdateCooldown } from "./checkAndUpdateCooldown";
export async function runAutomod(pluginData: PluginData<AutomodPluginType>, context: AutomodContext) {
export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
const userId = context.user?.id || context.member?.id || context.message?.user_id;
const user = context.user || (userId && pluginData.client.users.get(userId));
const member = context.member || (userId && pluginData.guild.members.get(userId));

View file

@ -1,12 +1,12 @@
import { User } from "eris";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
import { stripObjectToScalars } from "../../../utils";
export async function setAntiraidLevel(
pluginData: PluginData<AutomodPluginType>,
pluginData: GuildPluginData<AutomodPluginType>,
newLevel: string | null,
user?: User,
) {

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { Awaitable } from "knub/dist/utils";
import * as t from "io-ts";
import { AutomodContext, AutomodPluginType } from "./types";
@ -15,14 +15,14 @@ export interface AutomodTriggerMatchResult<TExtra extends any = unknown> {
type AutomodTriggerMatchFn<TConfigType, TMatchResultExtra> = (meta: {
ruleName: string;
pluginData: PluginData<AutomodPluginType>;
pluginData: GuildPluginData<AutomodPluginType>;
context: AutomodContext;
triggerConfig: TConfigType;
}) => Awaitable<null | AutomodTriggerMatchResult<TMatchResultExtra>>;
type AutomodTriggerRenderMatchInformationFn<TConfigType, TMatchResultExtra> = (meta: {
ruleName: string;
pluginData: PluginData<AutomodPluginType>;
pluginData: GuildPluginData<AutomodPluginType>;
contexts: AutomodContext[];
triggerConfig: TConfigType;
matchResult: AutomodTriggerMatchResult<TMatchResultExtra>;
@ -54,7 +54,7 @@ export function automodTrigger(...args) {
type AutomodActionApplyFn<TConfigType> = (meta: {
ruleName: string;
pluginData: PluginData<AutomodPluginType>;
pluginData: GuildPluginData<AutomodPluginType>;
contexts: AutomodContext[];
actionConfig: TConfigType;
matchResult: AutomodTriggerMatchResult;

View file

@ -1,7 +1,7 @@
import { ZeppelinPluginBlueprint } from "../ZeppelinPluginBlueprint";
import { ZeppelinGuildPluginBlueprint } from "../ZeppelinPluginBlueprint";
import { trimPluginDescription } from "../../utils";
export const pluginInfo: ZeppelinPluginBlueprint["info"] = {
export const pluginInfo: ZeppelinGuildPluginBlueprint["info"] = {
prettyName: "Automod",
description: trimPluginDescription(`
Allows specifying automated actions in response to triggers. Example use cases include word filtering and spam prevention.

View file

@ -1,4 +1,4 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
import { BotControlPluginType, ConfigSchema } from "./types";
import { GuildArchives } from "../../data/GuildArchives";
import { TextChannel } from "eris";
@ -16,7 +16,7 @@ const defaultOptions = {
},
};
export const BotControlPlugin = zeppelinPlugin<BotControlPluginType>()("bot_control", {
export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()("bot_control", {
configSchema: ConfigSchema,
defaultOptions,

View file

@ -1,9 +1,8 @@
import { command } from "knub";
import { BotControlPluginType } from "../types";
import { botControlCmd } from "../types";
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
export const LeaveServerCmd = command<BotControlPluginType>()({
export const LeaveServerCmd = botControlCmd({
trigger: ["leave_server", "leave_guild"],
permission: null,
config: {

View file

@ -1,10 +1,9 @@
import { command } from "knub";
import { BotControlPluginType } from "../types";
import { botControlCmd } from "../types";
import { isOwnerPreFilter } from "../../../pluginUtils";
import { getActiveReload, setActiveReload } from "../activeReload";
import { TextChannel } from "eris";
export const ReloadGlobalPluginsCmd = command<BotControlPluginType>()({
export const ReloadGlobalPluginsCmd = botControlCmd({
trigger: "bot_reload_global_plugins",
permission: null,
config: {

View file

@ -1,9 +1,8 @@
import { command } from "knub";
import { BotControlPluginType } from "../types";
import { botControlCmd } from "../types";
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
export const ReloadServerCmd = command<BotControlPluginType>()({
export const ReloadServerCmd = botControlCmd({
trigger: ["reload_server", "reload_guild"],
permission: null,
config: {

View file

@ -1,11 +1,10 @@
import { command } from "knub";
import { BotControlPluginType } from "../types";
import { botControlCmd } from "../types";
import { isOwnerPreFilter } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import escapeStringRegexp from "escape-string-regexp";
import { createChunkedMessage, getUser, sorter } from "../../../utils";
export const ServersCmd = command<BotControlPluginType>()({
export const ServersCmd = botControlCmd({
trigger: ["servers", "guilds"],
permission: null,
config: {

View file

@ -1,6 +1,6 @@
import * as t from "io-ts";
import { tNullable } from "../../utils";
import { BasePluginType } from "knub";
import { BasePluginType, globalCommand, globalEventListener } from "knub";
import { GuildArchives } from "../../data/GuildArchives";
export const ConfigSchema = t.type({
@ -15,3 +15,6 @@ export interface BotControlPluginType extends BasePluginType {
archives: GuildArchives;
};
}
export const botControlCmd = globalCommand<BotControlPluginType>();
export const botControlEvt = globalEventListener<BotControlPluginType>();

View file

@ -1,4 +1,4 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { CaseArgs, CaseNoteArgs, CasesPluginType, ConfigSchema } from "./types";
import { createCase } from "./functions/createCase";
import { GuildLogs } from "../../data/GuildLogs";
@ -26,7 +26,7 @@ const defaultOptions = {
},
};
export const CasesPlugin = zeppelinPlugin<CasesPluginType>()("cases", {
export const CasesPlugin = zeppelinGuildPlugin<CasesPluginType>()("cases", {
showInDocs: true,
info: {
prettyName: "Cases",

View file

@ -1,11 +1,11 @@
import { CaseArgs, CasesPluginType } from "../types";
import { resolveUser } from "../../../utils";
import { plugin, PluginData } from "knub";
import { GuildPluginData } from "knub";
import { createCaseNote } from "./createCaseNote";
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
import { logger } from "../../../logger";
export async function createCase(pluginData: PluginData<CasesPluginType>, args: CaseArgs) {
export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) {
const user = await resolveUser(pluginData.client, args.userId);
const userName = `${user.username}#${user.discriminator}`;

View file

@ -1,11 +1,11 @@
import { CaseNoteArgs, CasesPluginType } from "../types";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { resolveCaseId } from "./resolveCaseId";
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
import { resolveUser } from "../../../utils";
export async function createCaseNote(pluginData: PluginData<CasesPluginType>, args: CaseNoteArgs): Promise<void> {
export async function createCaseNote(pluginData: GuildPluginData<CasesPluginType>, args: CaseNoteArgs): Promise<void> {
const theCase = await pluginData.state.cases.find(resolveCaseId(args.caseId));
if (!theCase) {
throw new RecoverablePluginError(ERRORS.UNKNOWN_NOTE_CASE);

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
import { caseColors } from "../caseColors";
export function getCaseColor(pluginData: PluginData<CasesPluginType>, caseType: CaseTypes) {
export function getCaseColor(pluginData: GuildPluginData<CasesPluginType>, caseType: CaseTypes) {
return pluginData.config.get().case_colors?.[CaseTypeToName[caseType]] ?? caseColors[caseType];
}

View file

@ -2,7 +2,7 @@ import { Case } from "../../../data/entities/Case";
import { AdvancedMessageContent, MessageContent } from "eris";
import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes";
import { PluginData, helpers } from "knub";
import { GuildPluginData, helpers } from "knub";
import { CasesPluginType } from "../types";
import { resolveCaseId } from "./resolveCaseId";
import { chunkLines, chunkMessageLines, emptyEmbedValue, messageLink } from "../../../utils";
@ -10,7 +10,7 @@ import { getCaseColor } from "./getCaseColor";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
export async function getCaseEmbed(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
caseOrCaseId: Case | number,
requestMemberId?: string,
): Promise<AdvancedMessageContent> {

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
import { caseIcons } from "../caseIcons";
export function getCaseIcon(pluginData: PluginData<CasesPluginType>, caseType: CaseTypes) {
export function getCaseIcon(pluginData: GuildPluginData<CasesPluginType>, caseType: CaseTypes) {
return pluginData.config.get().case_icons?.[CaseTypeToName[caseType]] ?? caseIcons[caseType];
}

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import {
convertDelayStringToMS,
@ -24,7 +24,7 @@ const UPDATE_STR = "**[Update]**";
const RELATIVE_TIME_THRESHOLD = 7 * DAYS;
export async function getCaseSummary(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
caseOrCaseId: Case | number,
withLinks = false,
requestMemberId?: string,

View file

@ -1,9 +1,9 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { CaseTypes } from "../../../data/CaseTypes";
export async function getCaseTypeAmountForUserId(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
userID: string,
type: CaseTypes,
): Promise<number> {

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { Message, MessageContent, MessageFile, TextChannel } from "eris";
import { isDiscordRESTError } from "../../../utils";
@ -9,7 +9,7 @@ import { resolveCaseId } from "./resolveCaseId";
import { logger } from "../../../logger";
export async function postToCaseLogChannel(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
content: MessageContent,
file: MessageFile = null,
): Promise<Message | null> {
@ -40,7 +40,7 @@ export async function postToCaseLogChannel(
}
export async function postCaseToCaseLogChannel(
pluginData: PluginData<CasesPluginType>,
pluginData: GuildPluginData<CasesPluginType>,
caseOrCaseId: Case | number,
): Promise<Message | null> {
const theCase = await pluginData.state.cases.find(resolveCaseId(caseOrCaseId));

View file

@ -1,7 +1,7 @@
import * as t from "io-ts";
import { tDelayString, tPartialDictionary, tNullable } from "../../utils";
import { CaseNameToType, CaseTypes } from "../../data/CaseTypes";
import { BasePluginType } from "knub";
import { BasePluginType, guildCommand, guildEventListener } from "knub";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildCases } from "../../data/GuildCases";
import { GuildArchives } from "../../data/GuildArchives";

View file

@ -1,8 +1,8 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { PluginOptions } from "knub";
import { ConfigSchema, CensorPluginType } from "./types";
import { GuildLogs } from "src/data/GuildLogs";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { onMessageCreate } from "./util/onMessageCreate";
import { onMessageUpdate } from "./util/onMessageUpdate";
import { trimPluginDescription } from "../../utils";
@ -43,7 +43,7 @@ const defaultOptions: PluginOptions<CensorPluginType> = {
],
};
export const CensorPlugin = zeppelinPlugin<CensorPluginType>()("censor", {
export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()("censor", {
showInDocs: true,
info: {
prettyName: "Censor",

View file

@ -1,9 +1,9 @@
import * as t from "io-ts";
import { BasePluginType, eventListener } from "knub";
import { tNullable } from "src/utils";
import { TRegex } from "src/validatorUtils";
import { GuildLogs } from "src/data/GuildLogs";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { BasePluginType } from "knub";
import { tNullable } from "../../utils";
import { TRegex } from "../../validatorUtils";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { RegExpRunner } from "../../RegExpRunner";
export const ConfigSchema = t.type({
@ -35,5 +35,3 @@ export interface CensorPluginType extends BasePluginType {
onMessageUpdateFn;
};
}
export const censorEvent = eventListener<CensorPluginType>();

View file

@ -1,8 +1,8 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CensorPluginType } from "../types";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { AnyInvite, Embed, GuildInvite } from "eris";
import { ZalgoRegex } from "src/data/Zalgo";
import { ZalgoRegex } from "../../../data/Zalgo";
import {
getInviteCodesInString,
getUrlsInString,
@ -10,15 +10,15 @@ import {
resolveInvite,
isGuildInvite,
isRESTGuildInvite,
} from "src/utils";
} from "../../../utils";
import cloneDeep from "lodash.clonedeep";
import { censorMessage } from "./censorMessage";
import escapeStringRegexp from "escape-string-regexp";
import { logger } from "src/logger";
import { logger } from "../../../logger";
import { allowTimeout } from "../../../RegExpRunner";
export async function applyFiltersToMsg(
pluginData: PluginData<CensorPluginType>,
pluginData: GuildPluginData<CensorPluginType>,
savedMessage: SavedMessage,
): Promise<boolean> {
const member = await resolveMember(pluginData.client, pluginData.guild, savedMessage.user_id);

View file

@ -1,12 +1,12 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CensorPluginType } from "../types";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { LogType } from "src/data/LogType";
import { stripObjectToScalars, resolveUser } from "src/utils";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { LogType } from "../../../data/LogType";
import { stripObjectToScalars, resolveUser } from "../../../utils";
import { disableCodeBlocks, deactivateMentions } from "knub/dist/helpers";
export async function censorMessage(
pluginData: PluginData<CensorPluginType>,
pluginData: GuildPluginData<CensorPluginType>,
savedMessage: SavedMessage,
reason: string,
) {

View file

@ -1,9 +1,9 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CensorPluginType } from "../types";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { applyFiltersToMsg } from "./applyFiltersToMsg";
export async function onMessageCreate(pluginData: PluginData<CensorPluginType>, savedMessage: SavedMessage) {
export async function onMessageCreate(pluginData: GuildPluginData<CensorPluginType>, savedMessage: SavedMessage) {
if (savedMessage.is_bot) return;
const lock = await pluginData.locks.acquire(`message-${savedMessage.id}`);

View file

@ -1,9 +1,9 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CensorPluginType } from "../types";
import { SavedMessage } from "src/data/entities/SavedMessage";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { applyFiltersToMsg } from "./applyFiltersToMsg";
export async function onMessageUpdate(pluginData: PluginData<CensorPluginType>, savedMessage: SavedMessage) {
export async function onMessageUpdate(pluginData: GuildPluginData<CensorPluginType>, savedMessage: SavedMessage) {
if (savedMessage.is_bot) return;
const lock = await pluginData.locks.acquire(`message-${savedMessage.id}`);

View file

@ -1,10 +1,10 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { ChannelArchiverPluginType } from "./types";
import { ArchiveChannelCmd } from "./commands/ArchiveChannelCmd";
import * as t from "io-ts";
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
export const ChannelArchiverPlugin = zeppelinPlugin<ChannelArchiverPluginType>()("channel_archiver", {
export const ChannelArchiverPlugin = zeppelinGuildPlugin<ChannelArchiverPluginType>()("channel_archiver", {
showInDocs: false,
dependencies: [TimeAndDatePlugin],

View file

@ -1,7 +1,7 @@
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { channelArchiverCmd } from "../types";
import { isOwner, sendErrorMessage } from "src/pluginUtils";
import { confirm, SECONDS, noop } from "src/utils";
import { isOwner, sendErrorMessage } from "../../../pluginUtils";
import { confirm, SECONDS, noop } from "../../../utils";
import moment from "moment-timezone";
import { rehostAttachment } from "../rehostAttachment";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";

View file

@ -1,5 +1,5 @@
import { Attachment, TextChannel } from "eris";
import { downloadFile } from "src/utils";
import { downloadFile } from "../../utils";
import fs from "fs";
const fsp = fs.promises;

View file

@ -1,7 +1,7 @@
import { BasePluginType, command } from "knub";
import { BasePluginType, guildCommand } from "knub";
export interface ChannelArchiverPluginType extends BasePluginType {
state: {};
}
export const channelArchiverCmd = command<ChannelArchiverPluginType>();
export const channelArchiverCmd = guildCommand<ChannelArchiverPluginType>();

View file

@ -1,4 +1,4 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { CompanionChannelsPluginType, ConfigSchema, TCompanionChannelOpts } from "./types";
import { VoiceChannelJoinEvt } from "./events/VoiceChannelJoinEvt";
import { VoiceChannelSwitchEvt } from "./events/VoiceChannelSwitchEvt";
@ -13,7 +13,7 @@ const defaultOptions = {
},
};
export const CompanionChannelsPlugin = zeppelinPlugin<CompanionChannelsPluginType>()("companion_channels", {
export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPluginType>()("companion_channels", {
showInDocs: true,
info: {
prettyName: "Companion channels",

View file

@ -1,9 +1,8 @@
import { eventListener } from "knub";
import { CompanionChannelsPluginType } from "../types";
import { companionChannelsEvt } from "../types";
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
import { stripObjectToScalars } from "src/utils";
import { stripObjectToScalars } from "../../../utils";
export const VoiceChannelJoinEvt = eventListener<CompanionChannelsPluginType>()(
export const VoiceChannelJoinEvt = companionChannelsEvt(
"voiceChannelJoin",
({ pluginData, args: { member, newChannel } }) => {
handleCompanionPermissions(pluginData, member.id, newChannel);

View file

@ -1,8 +1,7 @@
import { eventListener } from "knub";
import { CompanionChannelsPluginType } from "../types";
import { companionChannelsEvt } from "../types";
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
export const VoiceChannelLeaveEvt = eventListener<CompanionChannelsPluginType>()(
export const VoiceChannelLeaveEvt = companionChannelsEvt(
"voiceChannelLeave",
({ pluginData, args: { member, oldChannel } }) => {
handleCompanionPermissions(pluginData, member.id, null, oldChannel);

View file

@ -1,8 +1,7 @@
import { eventListener } from "knub";
import { CompanionChannelsPluginType } from "../types";
import { companionChannelsEvt } from "../types";
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
export const VoiceChannelSwitchEvt = eventListener<CompanionChannelsPluginType>()(
export const VoiceChannelSwitchEvt = companionChannelsEvt(
"voiceChannelSwitch",
({ pluginData, args: { member, oldChannel, newChannel } }) => {
handleCompanionPermissions(pluginData, member.id, newChannel, oldChannel);

View file

@ -1,5 +1,5 @@
import { VoiceChannel } from "eris";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
@ -7,7 +7,7 @@ const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
};
export function getCompanionChannelOptsForVoiceChannelId(
pluginData: PluginData<CompanionChannelsPluginType>,
pluginData: GuildPluginData<CompanionChannelsPluginType>,
userId: string,
voiceChannel: VoiceChannel,
): TCompanionChannelOpts[] {

View file

@ -1,6 +1,6 @@
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
import { getCompanionChannelOptsForVoiceChannelId } from "./getCompanionChannelOptsForVoiceChannelId";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { TextChannel, VoiceChannel } from "eris";
import { isDiscordRESTError, MINUTES } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin";
@ -10,19 +10,19 @@ const ERROR_COOLDOWN_KEY = "errorCooldown";
const ERROR_COOLDOWN = 5 * MINUTES;
export async function handleCompanionPermissions(
pluginData: PluginData<CompanionChannelsPluginType>,
pluginData: GuildPluginData<CompanionChannelsPluginType>,
userId: string,
voiceChannel: VoiceChannel,
oldChannel?: VoiceChannel,
);
export async function handleCompanionPermissions(
pluginData: PluginData<CompanionChannelsPluginType>,
pluginData: GuildPluginData<CompanionChannelsPluginType>,
userId: string,
voiceChannel: null,
oldChannel: VoiceChannel,
);
export async function handleCompanionPermissions(
pluginData: PluginData<CompanionChannelsPluginType>,
pluginData: GuildPluginData<CompanionChannelsPluginType>,
userId: string,
voiceChannel?: VoiceChannel,
oldChannel?: VoiceChannel,

View file

@ -1,6 +1,6 @@
import * as t from "io-ts";
import { tNullable } from "../../utils";
import { BasePluginType, CooldownManager } from "knub";
import { BasePluginType, CooldownManager, guildEventListener } from "knub";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
@ -28,3 +28,5 @@ export interface CompanionChannelsPluginType extends BasePluginType {
errorCooldownManager: CooldownManager;
};
}
export const companionChannelsEvt = guildEventListener<CompanionChannelsPluginType>();

View file

@ -1,6 +1,6 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { ConfigSchema, CustomEventsPluginType } from "./types";
import { command, parseSignature } from "knub";
import { guildCommand, parseSignature } from "knub";
import { commandTypes } from "../../commandTypes";
import { stripObjectToScalars } from "../../utils";
import { runEvent } from "./functions/runEvent";
@ -11,7 +11,7 @@ const defaultOptions = {
},
};
export const CustomEventsPlugin = zeppelinPlugin<CustomEventsPluginType>()("custom_events", {
export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()("custom_events", {
showInDocs: false,
configSchema: ConfigSchema,
@ -22,7 +22,7 @@ export const CustomEventsPlugin = zeppelinPlugin<CustomEventsPluginType>()("cust
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 = command({
const eventCommand = guildCommand({
trigger: event.trigger.name,
permission: `events.${key}.trigger.can_use`,
signature,

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CustomEventsPluginType, TCustomEvent } from "../types";
import * as t from "io-ts";
import { renderTemplate } from "../../../templateFormatter";
@ -15,7 +15,7 @@ export const AddRoleAction = t.type({
export type TAddRoleAction = t.TypeOf<typeof AddRoleAction>;
export async function addRoleAction(
pluginData: PluginData<CustomEventsPluginType>,
pluginData: GuildPluginData<CustomEventsPluginType>,
action: TAddRoleAction,
values: any,
event: TCustomEvent,

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CustomEventsPluginType, TCustomEvent } from "../types";
import * as t from "io-ts";
import { renderTemplate } from "../../../templateFormatter";
@ -16,7 +16,7 @@ export const CreateCaseAction = t.type({
export type TCreateCaseAction = t.TypeOf<typeof CreateCaseAction>;
export async function createCaseAction(
pluginData: PluginData<CustomEventsPluginType>,
pluginData: GuildPluginData<CustomEventsPluginType>,
action: TCreateCaseAction,
values: any,
event: TCustomEvent,

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CustomEventsPluginType } from "../types";
import * as t from "io-ts";
import { renderTemplate } from "../../../templateFormatter";
@ -13,7 +13,7 @@ export const MessageAction = t.type({
export type TMessageAction = t.TypeOf<typeof MessageAction>;
export async function messageAction(
pluginData: PluginData<CustomEventsPluginType>,
pluginData: GuildPluginData<CustomEventsPluginType>,
action: TMessageAction,
values: any,
) {

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CustomEventsPluginType, TCustomEvent } from "../types";
import * as t from "io-ts";
import { renderTemplate } from "../../../templateFormatter";
@ -15,7 +15,7 @@ export const MoveToVoiceChannelAction = t.type({
export type TMoveToVoiceChannelAction = t.TypeOf<typeof MoveToVoiceChannelAction>;
export async function moveToVoiceChannelAction(
pluginData: PluginData<CustomEventsPluginType>,
pluginData: GuildPluginData<CustomEventsPluginType>,
action: TMoveToVoiceChannelAction,
values: any,
event: TCustomEvent,

View file

@ -1,4 +1,4 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { CustomEventsPluginType, TCustomEvent } from "../types";
import { sendErrorMessage } from "../../../pluginUtils";
import { ActionError } from "../ActionError";
@ -9,7 +9,7 @@ import { moveToVoiceChannelAction } from "../actions/moveToVoiceChannelAction";
import { messageAction } from "../actions/messageAction";
export async function runEvent(
pluginData: PluginData<CustomEventsPluginType>,
pluginData: GuildPluginData<CustomEventsPluginType>,
event: TCustomEvent,
eventData: any,
values: any,

View file

@ -1,5 +1,5 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { BasePluginType, eventListener, PluginData } from "knub";
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
import { BasePluginType, globalEventListener, GlobalPluginData } from "knub";
import * as t from "io-ts";
import { AllowedGuilds } from "../../data/AllowedGuilds";
import { Guild } from "eris";
@ -11,7 +11,7 @@ interface GuildAccessMonitorPluginType extends BasePluginType {
};
}
async function checkGuild(pluginData: PluginData<GuildAccessMonitorPluginType>, guild: Guild) {
async function checkGuild(pluginData: GlobalPluginData<GuildAccessMonitorPluginType>, guild: Guild) {
if (!(await pluginData.state.allowedGuilds.isAllowed(guild.id))) {
console.log(`Non-allowed server ${guild.name} (${guild.id}), leaving`);
guild.leave();
@ -21,11 +21,11 @@ async function checkGuild(pluginData: PluginData<GuildAccessMonitorPluginType>,
/**
* Global plugin to monitor if Zeppelin is invited to a non-whitelisted server, and leave it
*/
export const GuildAccessMonitorPlugin = zeppelinPlugin<GuildAccessMonitorPluginType>()("guild_access_monitor", {
export const GuildAccessMonitorPlugin = zeppelinGlobalPlugin<GuildAccessMonitorPluginType>()("guild_access_monitor", {
configSchema: t.type({}),
events: [
eventListener<GuildAccessMonitorPluginType>()("guildAvailable", ({ pluginData, args: { guild } }) => {
globalEventListener<GuildAccessMonitorPluginType>()("guildAvailable", ({ pluginData, args: { guild } }) => {
checkGuild(pluginData, guild);
}),
],

View file

@ -1,23 +1,26 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
import { GuildConfigReloaderPluginType } from "./types";
import { Configs } from "../../data/Configs";
import { reloadChangedGuilds } from "./functions/reloadChangedGuilds";
import * as t from "io-ts";
export const GuildConfigReloaderPlugin = zeppelinPlugin<GuildConfigReloaderPluginType>()("guild_config_reloader", {
showInDocs: false,
export const GuildConfigReloaderPlugin = zeppelinGlobalPlugin<GuildConfigReloaderPluginType>()(
"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 onLoad(pluginData) {
pluginData.state.guildConfigs = new Configs();
pluginData.state.highestConfigId = await pluginData.state.guildConfigs.getHighestId();
reloadChangedGuilds(pluginData);
reloadChangedGuilds(pluginData);
},
onUnload(pluginData) {
clearTimeout(pluginData.state.nextCheckTimeout);
pluginData.state.unloaded = true;
},
},
onUnload(pluginData) {
clearTimeout(pluginData.state.nextCheckTimeout);
pluginData.state.unloaded = true;
},
});
);

View file

@ -1,10 +1,10 @@
import { PluginData } from "knub";
import { GlobalPluginData } from "knub";
import { GuildConfigReloaderPluginType } from "../types";
import { SECONDS } from "../../../utils";
const CHECK_INTERVAL = 1 * SECONDS;
export async function reloadChangedGuilds(pluginData: PluginData<GuildConfigReloaderPluginType>) {
export async function reloadChangedGuilds(pluginData: GlobalPluginData<GuildConfigReloaderPluginType>) {
if (pluginData.state.unloaded) return;
const changedConfigs = await pluginData.state.guildConfigs.getActiveLargerThanId(pluginData.state.highestConfigId);

View file

@ -1,11 +1,11 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { PluginData } from "knub";
import { AllowedGuilds } from "src/data/AllowedGuilds";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { GuildPluginData } from "knub";
import { AllowedGuilds } from "../../data/AllowedGuilds";
import { GuildInfoSaverPluginType } from "./types";
import { MINUTES } from "src/utils";
import { MINUTES } from "../../utils";
import * as t from "io-ts";
export const GuildInfoSaverPlugin = zeppelinPlugin<GuildInfoSaverPluginType>()("guild_info_saver", {
export const GuildInfoSaverPlugin = zeppelinGuildPlugin<GuildInfoSaverPluginType>()("guild_info_saver", {
showInDocs: false,
configSchema: t.type({}),
@ -20,7 +20,7 @@ export const GuildInfoSaverPlugin = zeppelinPlugin<GuildInfoSaverPluginType>()("
},
});
function updateGuildInfo(pluginData: PluginData<GuildInfoSaverPluginType>) {
function updateGuildInfo(pluginData: GuildPluginData<GuildInfoSaverPluginType>) {
pluginData.state.allowedGuilds.updateInfo(
pluginData.guild.id,
pluginData.guild.name,

View file

@ -1,5 +1,5 @@
import { BasePluginType } from "knub";
import { AllowedGuilds } from "src/data/AllowedGuilds";
import { AllowedGuilds } from "../../data/AllowedGuilds";
export interface GuildInfoSaverPluginType extends BasePluginType {
state: {

View file

@ -1,7 +1,7 @@
import { PluginOptions } from "knub";
import { ConfigSchema, LocateUserPluginType } from "./types";
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { GuildVCAlerts } from "src/data/GuildVCAlerts";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { GuildVCAlerts } from "../../data/GuildVCAlerts";
import { outdatedAlertsLoop } from "./utils/outdatedLoop";
import { fillActiveAlertsList } from "./utils/fillAlertsList";
import { WhereCmd } from "./commands/WhereCmd";
@ -27,7 +27,7 @@ const defaultOptions: PluginOptions<LocateUserPluginType> = {
],
};
export const LocateUserPlugin = zeppelinPlugin<LocateUserPluginType>()("locate_user", {
export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()("locate_user", {
showInDocs: true,
info: {
prettyName: "Locate user",

View file

@ -1,11 +1,11 @@
import { locateUserCommand } from "../types";
import { locateUserCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import moment from "moment-timezone";
import humanizeDuration from "humanize-duration";
import { MINUTES, SECONDS } from "src/utils";
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
import { MINUTES, SECONDS } from "../../../utils";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
export const FollowCmd = locateUserCommand({
export const FollowCmd = locateUserCmd({
trigger: ["follow", "f"],
description: "Sets up an alert that notifies you any time `<member>` switches or joins voice channels",
usage: "!f 108552944961454080",

View file

@ -1,9 +1,9 @@
import { locateUserCommand } from "../types";
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
import { locateUserCmd } from "../types";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { createChunkedMessage, sorter } from "src/utils";
import { createChunkedMessage, sorter } from "../../../utils";
export const ListFollowCmd = locateUserCommand({
export const ListFollowCmd = locateUserCmd({
trigger: ["follows", "fs"],
description: "Displays all of your active alerts ordered by expiration time",
usage: "!fs",
@ -29,7 +29,7 @@ export const ListFollowCmd = locateUserCommand({
},
});
export const DeleteFollowCmd = locateUserCommand({
export const DeleteFollowCmd = locateUserCmd({
trigger: ["follows delete", "fs d"],
description:
"Deletes the alert at the position <num>.\nThe value needed for <num> can be found using `!follows` (`!fs`)",

View file

@ -1,9 +1,9 @@
import { locateUserCommand } from "../types";
import { locateUserCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { resolveMember } from "src/utils";
import { resolveMember } from "../../../utils";
import { sendWhere } from "../utils/sendWhere";
export const WhereCmd = locateUserCommand({
export const WhereCmd = locateUserCmd({
trigger: ["where", "w"],
description: "Posts an instant invite to the voice channel that `<member>` is in",
usage: "!w 108552944961454080",

View file

@ -1,6 +1,6 @@
import { locateUserEvent } from "../types";
import { locateUserEvt } from "../types";
export const GuildBanRemoveAlertsEvt = locateUserEvent({
export const GuildBanRemoveAlertsEvt = locateUserEvt({
event: "guildBanAdd",
async listener(meta) {

View file

@ -1,8 +1,8 @@
import { locateUserEvent } from "../types";
import { locateUserEvt } from "../types";
import { sendAlerts } from "../utils/sendAlerts";
import { TextableChannel, VoiceChannel } from "eris";
export const ChannelJoinAlertsEvt = locateUserEvent({
export const ChannelJoinAlertsEvt = locateUserEvt({
event: "voiceChannelJoin",
async listener(meta) {
@ -12,7 +12,7 @@ export const ChannelJoinAlertsEvt = locateUserEvent({
},
});
export const ChannelSwitchAlertsEvt = locateUserEvent({
export const ChannelSwitchAlertsEvt = locateUserEvt({
event: "voiceChannelSwitch",
async listener(meta) {
@ -22,7 +22,7 @@ export const ChannelSwitchAlertsEvt = locateUserEvent({
},
});
export const ChannelLeaveAlertsEvt = locateUserEvent({
export const ChannelLeaveAlertsEvt = locateUserEvt({
event: "voiceChannelLeave",
async listener(meta) {

View file

@ -1,5 +1,7 @@
import * as t from "io-ts";
import { BasePluginType, command, eventListener } from "knub";
import { BasePluginType, guildCommand, guildEventListener } from "knub";
import { GuildVCAlerts } from "../../data/GuildVCAlerts";
import Timeout = NodeJS.Timeout;
export const ConfigSchema = t.type({
can_where: t.boolean,
@ -9,7 +11,13 @@ export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
export interface LocateUserPluginType extends BasePluginType {
config: TConfigSchema;
state: {
alerts: GuildVCAlerts;
outdatedAlertsTimeout: Timeout;
usersWithAlerts: string[];
unloaded: boolean;
};
}
export const locateUserCommand = command<LocateUserPluginType>();
export const locateUserEvent = eventListener<LocateUserPluginType>();
export const locateUserCmd = guildCommand<LocateUserPluginType>();
export const locateUserEvt = guildEventListener<LocateUserPluginType>();

View file

@ -1,4 +1,7 @@
export async function fillActiveAlertsList(pluginData) {
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
export async function fillActiveAlertsList(pluginData: GuildPluginData<LocateUserPluginType>) {
const allAlerts = await pluginData.state.alerts.getAllGuildAlerts();
allAlerts.forEach(alert => {

View file

@ -1,10 +1,10 @@
import { Member, TextableChannel } from "eris";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { sendErrorMessage } from "src/pluginUtils";
import { sendErrorMessage } from "../../../pluginUtils";
export async function moveMember(
pluginData: PluginData<LocateUserPluginType>,
pluginData: GuildPluginData<LocateUserPluginType>,
toMoveID: string,
target: Member,
errorChannel: TextableChannel,

View file

@ -1,9 +1,11 @@
import { SECONDS } from "src/utils";
import { SECONDS } from "../../../utils";
import { removeUserIdFromActiveAlerts } from "./removeUserIdFromActiveAlerts";
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
const ALERT_LOOP_TIME = 30 * SECONDS;
export async function outdatedAlertsLoop(pluginData) {
export async function outdatedAlertsLoop(pluginData: GuildPluginData<LocateUserPluginType>) {
const outdatedAlerts = await pluginData.state.alerts.getOutdatedAlerts();
for (const alert of outdatedAlerts) {

View file

@ -1,4 +1,7 @@
export async function removeUserIdFromActiveAlerts(pluginData, userId: string) {
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
export async function removeUserIdFromActiveAlerts(pluginData: GuildPluginData<LocateUserPluginType>, userId: string) {
const index = pluginData.state.usersWithAlerts.indexOf(userId);
if (index > -1) {
pluginData.state.usersWithAlerts.splice(index, 1);

View file

@ -1,11 +1,11 @@
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { resolveMember } from "src/utils";
import { resolveMember } from "../../../utils";
import { sendWhere } from "./sendWhere";
import { TextableChannel } from "eris";
import { moveMember } from "./moveMember";
export async function sendAlerts(pluginData: PluginData<LocateUserPluginType>, userId: string) {
export async function sendAlerts(pluginData: GuildPluginData<LocateUserPluginType>, userId: string) {
const triggeredAlerts = await pluginData.state.alerts.getAlertsByUserId(userId);
const member = await resolveMember(pluginData.client, pluginData.guild, userId);

View file

@ -1,12 +1,12 @@
import { Member, TextableChannel, VoiceChannel } from "eris";
import { getInviteLink } from "knub/dist/helpers";
import { createOrReuseInvite } from "./createOrReuseInvite";
import { PluginData } from "knub";
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { sendErrorMessage } from "../../../pluginUtils";
export async function sendWhere(
pluginData: PluginData<LocateUserPluginType>,
pluginData: GuildPluginData<LocateUserPluginType>,
member: Member,
channel: TextableChannel,
prepend: string,

View file

@ -1,17 +1,17 @@
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { PluginOptions } from "knub";
import { ConfigSchema, LogsPluginType } from "./types";
import DefaultLogMessages from "../../data/DefaultLogMessages.json";
import { GuildLogs } from "src/data/GuildLogs";
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
import { GuildArchives } from "src/data/GuildArchives";
import { GuildCases } from "src/data/GuildCases";
import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildArchives } from "../../data/GuildArchives";
import { GuildCases } from "../../data/GuildCases";
import { onMessageDelete } from "./util/onMessageDelete";
import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk";
import { onMessageUpdate } from "./util/onMessageUpdate";
import { LogsGuildMemberAddEvt } from "./events/LogsGuildMemberAddEvt";
import { LogsGuildMemberRemoveEvt } from "./events/LogsGuildMemberRemoveEvt";
import { LogsGuildMemberUpdateEvt, LogsUserUpdateEvt } from "./events/LogsUserUpdateEvts";
import { LogsGuildMemberUpdateEvt } from "./events/LogsUserUpdateEvts";
import { LogsChannelCreateEvt, LogsChannelDeleteEvt } from "./events/LogsChannelModifyEvts";
import { LogsRoleCreateEvt, LogsRoleDeleteEvt } from "./events/LogsRoleModifyEvts";
import { LogsVoiceJoinEvt, LogsVoiceLeaveEvt, LogsVoiceSwitchEvt } from "./events/LogsVoiceChannelEvts";
@ -44,7 +44,7 @@ const defaultOptions: PluginOptions<LogsPluginType> = {
],
};
export const LogsPlugin = zeppelinPlugin<LogsPluginType>()("logs", {
export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()("logs", {
showInDocs: true,
info: {
prettyName: "Logs",
@ -58,7 +58,6 @@ export const LogsPlugin = zeppelinPlugin<LogsPluginType>()("logs", {
LogsGuildMemberAddEvt,
LogsGuildMemberRemoveEvt,
LogsGuildMemberUpdateEvt,
LogsUserUpdateEvt,
LogsChannelCreateEvt,
LogsChannelDeleteEvt,
LogsRoleCreateEvt,

View file

@ -1,8 +1,8 @@
import { logsEvent } from "../types";
import { stripObjectToScalars } from "src/utils";
import { LogType } from "src/data/LogType";
import { logsEvt } from "../types";
import { stripObjectToScalars } from "../../../utils";
import { LogType } from "../../../data/LogType";
export const LogsChannelCreateEvt = logsEvent({
export const LogsChannelCreateEvt = logsEvt({
event: "channelCreate",
async listener(meta) {
@ -12,7 +12,7 @@ export const LogsChannelCreateEvt = logsEvent({
},
});
export const LogsChannelDeleteEvt = logsEvent({
export const LogsChannelDeleteEvt = logsEvt({
event: "channelDelete",
async listener(meta) {

View file

@ -1,10 +1,10 @@
import { logsEvent } from "../types";
import { stripObjectToScalars, UnknownUser } from "src/utils";
import { LogType } from "src/data/LogType";
import { logsEvt } from "../types";
import { stripObjectToScalars, UnknownUser } from "../../../utils";
import { LogType } from "../../../data/LogType";
import { Constants as ErisConstants } from "eris";
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
export const LogsGuildBanAddEvt = logsEvent({
export const LogsGuildBanAddEvt = logsEvt({
event: "guildBanAdd",
async listener(meta) {
@ -29,7 +29,7 @@ export const LogsGuildBanAddEvt = logsEvent({
},
});
export const LogsGuildBanRemoveEvt = logsEvent({
export const LogsGuildBanRemoveEvt = logsEvt({
event: "guildBanRemove",
async listener(meta) {

Some files were not shown because too many files have changed in this diff Show more