mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Update to new Knub 30 beta. Code clean-up.
This commit is contained in:
parent
5d579446c5
commit
2f470dc37a
299 changed files with 1075 additions and 1004 deletions
21
backend/package-lock.json
generated
21
backend/package-lock.json
generated
|
@ -1010,6 +1010,7 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"anymatch": "~3.1.1",
|
"anymatch": "~3.1.1",
|
||||||
"braces": "~3.0.2",
|
"braces": "~3.0.2",
|
||||||
|
"fsevents": "~2.1.2",
|
||||||
"glob-parent": "~5.1.0",
|
"glob-parent": "~5.1.0",
|
||||||
"is-binary-path": "~2.1.0",
|
"is-binary-path": "~2.1.0",
|
||||||
"is-glob": "~4.0.1",
|
"is-glob": "~4.0.1",
|
||||||
|
@ -1841,6 +1842,13 @@
|
||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
"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": {
|
"function-bind": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||||
|
@ -2364,19 +2372,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"knub": {
|
"knub": {
|
||||||
"version": "30.0.0-beta.21",
|
"version": "30.0.0-beta.23",
|
||||||
"resolved": "https://registry.npmjs.org/knub/-/knub-30.0.0-beta.21.tgz",
|
"resolved": "https://registry.npmjs.org/knub/-/knub-30.0.0-beta.23.tgz",
|
||||||
"integrity": "sha512-BkMLgqqw7AroarZpsQ0wK93Yk2cFBRJa8GmFPYogiXEDTA/47oQ+A21SpbRCfZ2sCxFdjdZPUZIPqgjG38H7YQ==",
|
"integrity": "sha512-kBlQQAc6IPqyVA832wR567qUdE2EZIJUGTgUQE8NGmx7MxQrqZ7yvK1+Mkzh3HlNBgnrAgMorRimQHeO+xEXxw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"knub-command-manager": "^8.1.2",
|
"knub-command-manager": "^8.1.2",
|
||||||
"ts-essentials": "^6.0.7"
|
"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": {
|
"knub-command-manager": {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"humanize-duration": "^3.15.0",
|
"humanize-duration": "^3.15.0",
|
||||||
"io-ts": "^2.0.0",
|
"io-ts": "^2.0.0",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"knub": "^30.0.0-beta.21",
|
"knub": "^30.0.0-beta.23",
|
||||||
"knub-command-manager": "^8.1.2",
|
"knub-command-manager": "^8.1.2",
|
||||||
"last-commit-log": "^2.1.0",
|
"last-commit-log": "^2.1.0",
|
||||||
"lodash.chunk": "^4.2.0",
|
"lodash.chunk": "^4.2.0",
|
||||||
|
|
|
@ -3,27 +3,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Member } from "eris";
|
import { Member } from "eris";
|
||||||
import {
|
import { CommandContext, configUtils, ConfigValidationError, GuildPluginData, helpers, PluginOptions } from "knub";
|
||||||
CommandContext,
|
|
||||||
configUtils,
|
|
||||||
ConfigValidationError,
|
|
||||||
helpers,
|
|
||||||
PluginBlueprint,
|
|
||||||
PluginData,
|
|
||||||
PluginOptions,
|
|
||||||
} from "knub";
|
|
||||||
import { decodeAndValidateStrict, StrictValidationError, validate } from "./validatorUtils";
|
import { decodeAndValidateStrict, StrictValidationError, validate } from "./validatorUtils";
|
||||||
import { deepKeyIntersect, errorMessage, successMessage, tDeepPartial, tNullable } from "./utils";
|
import { deepKeyIntersect, errorMessage, successMessage, tDeepPartial, tNullable } from "./utils";
|
||||||
import { ZeppelinPluginBlueprint } from "./plugins/ZeppelinPluginBlueprint";
|
|
||||||
import { TZeppelinKnub } from "./types";
|
import { TZeppelinKnub } from "./types";
|
||||||
import { ExtendedMatchParams } from "knub/dist/config/PluginConfigManager"; // TODO: Export from Knub index
|
import { ExtendedMatchParams } from "knub/dist/config/PluginConfigManager"; // TODO: Export from Knub index
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { PluginOverrideCriteria } from "knub/dist/config/configTypes";
|
import { PluginOverrideCriteria } from "knub/dist/config/configTypes";
|
||||||
import { Tail } from "./utils/typeUtils";
|
import { Tail } from "./utils/typeUtils";
|
||||||
|
import { AnyPluginData } from "knub/dist/plugins/PluginData";
|
||||||
|
import { ZeppelinPlugin } from "./plugins/ZeppelinPlugin";
|
||||||
|
|
||||||
const { getMemberLevel } = helpers;
|
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) {
|
if (member2.id === pluginData.client.user.id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +26,7 @@ export function canActOn(pluginData: PluginData<any>, member1: Member, member2:
|
||||||
return allowSameLevel ? ourLevel >= memberLevel : ourLevel > memberLevel;
|
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);
|
const config = pluginData.config.getMatchingConfig(matchParams);
|
||||||
return helpers.hasPermission(config, permission);
|
return helpers.hasPermission(config, permission);
|
||||||
}
|
}
|
||||||
|
@ -71,8 +64,8 @@ export function strictValidationErrorToConfigValidationError(err: StrictValidati
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPluginConfigPreprocessor(
|
export function getPluginConfigPreprocessor(
|
||||||
blueprint: ZeppelinPluginBlueprint,
|
blueprint: ZeppelinPlugin,
|
||||||
customPreprocessor?: PluginBlueprint<any>["configPreprocessor"],
|
customPreprocessor?: ZeppelinPlugin["configPreprocessor"],
|
||||||
) {
|
) {
|
||||||
return async (options: PluginOptions<any>) => {
|
return async (options: PluginOptions<any>) => {
|
||||||
// 1. Validate the basic structure of plugin config
|
// 1. Validate the basic structure of plugin config
|
||||||
|
@ -141,22 +134,22 @@ export function getPluginConfigPreprocessor(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sendSuccessMessage(pluginData: PluginData<any>, channel, body) {
|
export function sendSuccessMessage(pluginData: AnyPluginData<any>, channel, body) {
|
||||||
const emoji = pluginData.guildConfig.success_emoji || undefined;
|
const emoji = pluginData.fullConfig.success_emoji || undefined;
|
||||||
return channel.createMessage(successMessage(body, emoji));
|
return channel.createMessage(successMessage(body, emoji));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sendErrorMessage(pluginData: PluginData<any>, channel, body) {
|
export function sendErrorMessage(pluginData: AnyPluginData<any>, channel, body) {
|
||||||
const emoji = pluginData.guildConfig.error_emoji || undefined;
|
const emoji = pluginData.fullConfig.error_emoji || undefined;
|
||||||
return channel.createMessage(errorMessage(body, emoji));
|
return channel.createMessage(errorMessage(body, emoji));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBaseUrl(pluginData: PluginData<any>) {
|
export function getBaseUrl(pluginData: AnyPluginData<any>) {
|
||||||
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
||||||
return knub.getGlobalConfig().url;
|
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 knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
||||||
const owners = knub.getGlobalConfig().owners;
|
const owners = knub.getGlobalConfig().owners;
|
||||||
if (!owners) {
|
if (!owners) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginOptions } from "knub";
|
import { PluginOptions } from "knub";
|
||||||
import { AutoDeletePluginType, ConfigSchema } from "./types";
|
import { AutoDeletePluginType, ConfigSchema } from "./types";
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
import { GuildLogs } from "src/data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { onMessageCreate } from "./util/onMessageCreate";
|
import { onMessageCreate } from "./util/onMessageCreate";
|
||||||
import { onMessageDelete } from "./util/onMessageDelete";
|
import { onMessageDelete } from "./util/onMessageDelete";
|
||||||
import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk";
|
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,
|
showInDocs: true,
|
||||||
info: {
|
info: {
|
||||||
prettyName: "Auto-delete",
|
prettyName: "Auto-delete",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { BasePluginType } from "knub";
|
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||||
import { tDelayString, MINUTES } from "src/utils";
|
import { tDelayString, MINUTES } from "../../utils";
|
||||||
import { GuildLogs } from "src/data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../data/entities/SavedMessage";
|
||||||
|
|
||||||
export const MAX_DELAY = 5 * MINUTES;
|
export const MAX_DELAY = 5 * MINUTES;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutoDeletePluginType } from "../types";
|
import { AutoDeletePluginType } from "../types";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { scheduleNextDeletion } from "./scheduleNextDeletion";
|
import { scheduleNextDeletion } from "./scheduleNextDeletion";
|
||||||
import { sorter } from "src/utils";
|
import { sorter } from "../../../utils";
|
||||||
|
|
||||||
export function addMessageToDeletionQueue(
|
export function addMessageToDeletionQueue(
|
||||||
pluginData: PluginData<AutoDeletePluginType>,
|
pluginData: GuildPluginData<AutoDeletePluginType>,
|
||||||
msg: SavedMessage,
|
msg: SavedMessage,
|
||||||
delay: number,
|
delay: number,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutoDeletePluginType } from "../types";
|
import { AutoDeletePluginType } from "../types";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { LogType } from "src/data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { stripObjectToScalars, resolveUser } from "src/utils";
|
import { stripObjectToScalars, resolveUser } from "../../../utils";
|
||||||
import { logger } from "src/logger";
|
import { logger } from "../../../logger";
|
||||||
import { scheduleNextDeletion } from "./scheduleNextDeletion";
|
import { scheduleNextDeletion } from "./scheduleNextDeletion";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
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);
|
const [itemToDelete] = pluginData.state.deletionQueue.splice(0, 1);
|
||||||
if (!itemToDelete) return;
|
if (!itemToDelete) return;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { AutoDeletePluginType, MAX_DELAY } from "../types";
|
import { AutoDeletePluginType, MAX_DELAY } from "../types";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { convertDelayStringToMS, resolveMember } from "src/utils";
|
import { convertDelayStringToMS, resolveMember } from "../../../utils";
|
||||||
import { LogType } from "src/data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { addMessageToDeletionQueue } from "./addMessageToDeletionQueue";
|
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 member = await resolveMember(pluginData.client, pluginData.guild, msg.user_id);
|
||||||
const config = pluginData.config.getMatchingConfig({ member, channelId: msg.channel_id });
|
const config = pluginData.config.getMatchingConfig({ member, channelId: msg.channel_id });
|
||||||
if (config.enabled) {
|
if (config.enabled) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutoDeletePluginType } from "../types";
|
import { AutoDeletePluginType } from "../types";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { scheduleNextDeletion } from "./scheduleNextDeletion";
|
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);
|
const indexToDelete = pluginData.state.deletionQueue.findIndex(item => item.message.id === msg.id);
|
||||||
if (indexToDelete > -1) {
|
if (indexToDelete > -1) {
|
||||||
pluginData.state.deletionQueue.splice(indexToDelete, 1);
|
pluginData.state.deletionQueue.splice(indexToDelete, 1);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { AutoDeletePluginType } from "../types";
|
import { AutoDeletePluginType } from "../types";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { onMessageDelete } from "./onMessageDelete";
|
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) {
|
for (const msg of messages) {
|
||||||
onMessageDelete(pluginData, msg);
|
onMessageDelete(pluginData, msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutoDeletePluginType } from "../types";
|
import { AutoDeletePluginType } from "../types";
|
||||||
import { deleteNextItem } from "./deleteNextItem";
|
import { deleteNextItem } from "./deleteNextItem";
|
||||||
|
|
||||||
export function scheduleNextDeletion(pluginData: PluginData<AutoDeletePluginType>) {
|
export function scheduleNextDeletion(pluginData: GuildPluginData<AutoDeletePluginType>) {
|
||||||
if (pluginData.state.deletionQueue.length === 0) {
|
if (pluginData.state.deletionQueue.length === 0) {
|
||||||
clearTimeout(pluginData.state.nextDeletionTimeout);
|
clearTimeout(pluginData.state.nextDeletionTimeout);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { AutoReactionsPluginType, ConfigSchema } from "./types";
|
import { AutoReactionsPluginType, ConfigSchema } from "./types";
|
||||||
import { PluginOptions } from "knub";
|
import { PluginOptions } from "knub";
|
||||||
import { NewAutoReactionsCmd } from "./commands/NewAutoReactionsCmd";
|
import { NewAutoReactionsCmd } from "./commands/NewAutoReactionsCmd";
|
||||||
import { DisableAutoReactionsCmd } from "./commands/DisableAutoReactionsCmd";
|
import { DisableAutoReactionsCmd } from "./commands/DisableAutoReactionsCmd";
|
||||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
import { GuildAutoReactions } from "src/data/GuildAutoReactions";
|
import { GuildAutoReactions } from "../../data/GuildAutoReactions";
|
||||||
import { AddReactionsEvt } from "./events/AddReactionsEvt";
|
import { AddReactionsEvt } from "./events/AddReactionsEvt";
|
||||||
import { trimPluginDescription } from "../../utils";
|
import { trimPluginDescription } from "../../utils";
|
||||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
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,
|
showInDocs: true,
|
||||||
info: {
|
info: {
|
||||||
prettyName: "Auto-reactions",
|
prettyName: "Auto-reactions",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { autoReactionsCmd } from "../types";
|
import { autoReactionsCmd } from "../types";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
|
|
||||||
export const DisableAutoReactionsCmd = autoReactionsCmd({
|
export const DisableAutoReactionsCmd = autoReactionsCmd({
|
||||||
trigger: "auto_reactions disable",
|
trigger: "auto_reactions disable",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { autoReactionsCmd } from "../types";
|
import { autoReactionsCmd } from "../types";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { canUseEmoji, customEmojiRegex, isEmoji } from "src/utils";
|
import { canUseEmoji, customEmojiRegex, isEmoji } from "../../../utils";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
|
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
|
||||||
import { Constants, GuildChannel } from "eris";
|
import { Constants, GuildChannel } from "eris";
|
||||||
import { readChannelPermissions } from "../../../utils/readChannelPermissions";
|
import { readChannelPermissions } from "../../../utils/readChannelPermissions";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { autoReactionsEvt } from "../types";
|
import { autoReactionsEvt } from "../types";
|
||||||
import { isDiscordRESTError } from "src/utils";
|
import { isDiscordRESTError } from "../../../utils";
|
||||||
import { LogType } from "src/data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { logger } from "../../../logger";
|
import { logger } from "../../../logger";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
import { Constants, GuildChannel } from "eris";
|
import { Constants, GuildChannel } from "eris";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { BasePluginType, command, eventListener } from "knub";
|
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||||
import { GuildLogs } from "src/data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
import { GuildAutoReactions } from "src/data/GuildAutoReactions";
|
import { GuildAutoReactions } from "../../data/GuildAutoReactions";
|
||||||
|
|
||||||
export const ConfigSchema = t.type({
|
export const ConfigSchema = t.type({
|
||||||
can_manage: t.boolean,
|
can_manage: t.boolean,
|
||||||
|
@ -18,5 +18,5 @@ export interface AutoReactionsPluginType extends BasePluginType {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const autoReactionsCmd = command<AutoReactionsPluginType>();
|
export const autoReactionsCmd = guildCommand<AutoReactionsPluginType>();
|
||||||
export const autoReactionsEvt = eventListener<AutoReactionsPluginType>();
|
export const autoReactionsEvt = guildEventListener<AutoReactionsPluginType>();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { AutomodPluginType, ConfigSchema } from "./types";
|
import { AutomodPluginType, ConfigSchema } from "./types";
|
||||||
import { RunAutomodOnJoinEvt } from "./events/RunAutomodOnJoinEvt";
|
import { RunAutomodOnJoinEvt } from "./events/RunAutomodOnJoinEvt";
|
||||||
import { GuildLogs } from "../../data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
|
@ -147,7 +147,7 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AutomodPlugin = zeppelinPlugin<AutomodPluginType>()("automod", {
|
export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()("automod", {
|
||||||
showInDocs: true,
|
showInDocs: true,
|
||||||
info: pluginInfo,
|
info: pluginInfo,
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { command } from "knub";
|
import { guildCommand, GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
||||||
import { sendSuccessMessage } from "../../../pluginUtils";
|
import { sendSuccessMessage } from "../../../pluginUtils";
|
||||||
|
|
||||||
export const AntiraidClearCmd = command<AutomodPluginType>()({
|
export const AntiraidClearCmd = guildCommand<AutomodPluginType>()({
|
||||||
trigger: ["antiraid clear", "antiraid reset", "antiraid none", "antiraid off"],
|
trigger: ["antiraid clear", "antiraid reset", "antiraid none", "antiraid off"],
|
||||||
permission: "can_set_antiraid",
|
permission: "can_set_antiraid",
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { command } from "knub";
|
import { guildCommand, GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
|
|
||||||
export const SetAntiraidCmd = command<AutomodPluginType>()({
|
export const SetAntiraidCmd = guildCommand<AutomodPluginType>()({
|
||||||
trigger: "antiraid",
|
trigger: "antiraid",
|
||||||
permission: "can_set_antiraid",
|
permission: "can_set_antiraid",
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { command } from "knub";
|
import { guildCommand, GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
import { setAntiraidLevel } from "../functions/setAntiraidLevel";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
|
|
||||||
export const ViewAntiraidCmd = command<AutomodPluginType>()({
|
export const ViewAntiraidCmd = guildCommand<AutomodPluginType>()({
|
||||||
trigger: "antiraid",
|
trigger: "antiraid",
|
||||||
permission: "can_view_antiraid",
|
permission: "can_view_antiraid",
|
||||||
|
|
||||||
async run({ pluginData, message, args }) {
|
async run({ pluginData, message }) {
|
||||||
if (pluginData.state.cachedAntiraidLevel) {
|
if (pluginData.state.cachedAntiraidLevel) {
|
||||||
message.channel.createMessage(`Anti-raid is set to **${pluginData.state.cachedAntiraidLevel}**`);
|
message.channel.createMessage(`Anti-raid is set to **${pluginData.state.cachedAntiraidLevel}**`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { eventListener } from "knub";
|
import { guildEventListener } from "knub";
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { runAutomod } from "../functions/runAutomod";
|
import { runAutomod } from "../functions/runAutomod";
|
||||||
import { RecentActionType } from "../constants";
|
import { RecentActionType } from "../constants";
|
||||||
|
|
||||||
export const RunAutomodOnJoinEvt = eventListener<AutomodPluginType>()(
|
export const RunAutomodOnJoinEvt = guildEventListener<AutomodPluginType>()(
|
||||||
"guildMemberAdd",
|
"guildMemberAdd",
|
||||||
({ pluginData, args: { member } }) => {
|
({ pluginData, args: { member } }) => {
|
||||||
const context: AutomodContext = {
|
const context: AutomodContext = {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { eventListener } from "knub";
|
import { guildEventListener } from "knub";
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { RecentActionType } from "../constants";
|
import { RecentActionType } from "../constants";
|
||||||
import { runAutomod } from "../functions/runAutomod";
|
import { runAutomod } from "../functions/runAutomod";
|
||||||
import isEqual from "lodash.isequal";
|
import isEqual from "lodash.isequal";
|
||||||
import diff from "lodash.difference";
|
import diff from "lodash.difference";
|
||||||
|
|
||||||
export const RunAutomodOnMemberUpdate = eventListener<AutomodPluginType>()(
|
export const RunAutomodOnMemberUpdate = guildEventListener<AutomodPluginType>()(
|
||||||
"guildMemberUpdate",
|
"guildMemberUpdate",
|
||||||
({ pluginData, args: { member, oldMember } }) => {
|
({ pluginData, args: { member, oldMember } }) => {
|
||||||
if (!oldMember) return;
|
if (!oldMember) return;
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { runAutomod } from "../functions/runAutomod";
|
import { runAutomod } from "../functions/runAutomod";
|
||||||
import { addRecentActionsFromMessage } from "../functions/addRecentActionsFromMessage";
|
import { addRecentActionsFromMessage } from "../functions/addRecentActionsFromMessage";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { clearRecentActionsForMessage } from "../functions/clearRecentActionsForMessage";
|
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 user = pluginData.client.users.get(message.user_id);
|
||||||
const member = pluginData.guild.members.get(message.user_id);
|
const member = pluginData.guild.members.get(message.user_id);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";
|
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";
|
||||||
import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils";
|
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 globalIdentifier = context.message.user_id;
|
||||||
const perChannelIdentifier = `${context.message.channel_id}-${context.message.user_id}`;
|
const perChannelIdentifier = `${context.message.channel_id}-${context.message.user_id}`;
|
||||||
const expiresAt = Date.now() + RECENT_ACTION_EXPIRY_TIME;
|
const expiresAt = Date.now() + RECENT_ACTION_EXPIRY_TIME;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { AutomodContext, AutomodPluginType, TRule } from "../types";
|
import { AutomodContext, AutomodPluginType, TRule } from "../types";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodTriggerMatchResult } from "../helpers";
|
import { AutomodTriggerMatchResult } from "../helpers";
|
||||||
import { convertDelayStringToMS } from "../../../utils";
|
import { convertDelayStringToMS } from "../../../utils";
|
||||||
|
|
||||||
export function checkAndUpdateCooldown(
|
export function checkAndUpdateCooldown(
|
||||||
pluginData: PluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
rule: TRule,
|
rule: TRule,
|
||||||
context: AutomodContext,
|
context: AutomodContext,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { RECENT_NICKNAME_CHANGE_EXPIRY_TIME, RECENT_SPAM_EXPIRY_TIME } from "../constants";
|
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();
|
const now = Date.now();
|
||||||
for (const [userId, { timestamp }] of pluginData.state.recentNicknameChanges) {
|
for (const [userId, { timestamp }] of pluginData.state.recentNicknameChanges) {
|
||||||
if (timestamp + RECENT_NICKNAME_CHANGE_EXPIRY_TIME <= now) {
|
if (timestamp + RECENT_NICKNAME_CHANGE_EXPIRY_TIME <= now) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { RECENT_ACTION_EXPIRY_TIME } from "../constants";
|
import { RECENT_ACTION_EXPIRY_TIME } from "../constants";
|
||||||
|
|
||||||
export function clearOldRecentActions(pluginData: PluginData<AutomodPluginType>) {
|
export function clearOldRecentActions(pluginData: GuildPluginData<AutomodPluginType>) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
pluginData.state.recentActions = pluginData.state.recentActions.filter(info => {
|
pluginData.state.recentActions = pluginData.state.recentActions.filter(info => {
|
||||||
return info.context.timestamp + RECENT_ACTION_EXPIRY_TIME > now;
|
return info.context.timestamp + RECENT_ACTION_EXPIRY_TIME > now;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { RECENT_SPAM_EXPIRY_TIME } from "../constants";
|
import { RECENT_SPAM_EXPIRY_TIME } from "../constants";
|
||||||
|
|
||||||
export function clearOldRecentSpam(pluginData: PluginData<AutomodPluginType>) {
|
export function clearOldRecentSpam(pluginData: GuildPluginData<AutomodPluginType>) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
pluginData.state.recentSpam = pluginData.state.recentSpam.filter(spam => {
|
pluginData.state.recentSpam = pluginData.state.recentSpam.filter(spam => {
|
||||||
return spam.timestamp + RECENT_SPAM_EXPIRY_TIME > now;
|
return spam.timestamp + RECENT_SPAM_EXPIRY_TIME > now;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";
|
import { RECENT_ACTION_EXPIRY_TIME, RecentActionType } from "../constants";
|
||||||
import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils";
|
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 globalIdentifier = context.message.user_id;
|
||||||
const perChannelIdentifier = `${context.message.channel_id}-${context.message.user_id}`;
|
const perChannelIdentifier = `${context.message.channel_id}-${context.message.user_id}`;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { RecentActionType } from "../constants";
|
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 pluginData.state.recentSpam.find(spam => {
|
||||||
return spam.type === type && (!identifier || spam.identifiers.includes(identifier));
|
return spam.type === type && (!identifier || spam.identifiers.includes(identifier));
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
@ -6,7 +6,7 @@ import { getMatchingRecentActions } from "./getMatchingRecentActions";
|
||||||
import { RecentActionType } from "../constants";
|
import { RecentActionType } from "../constants";
|
||||||
|
|
||||||
export function getMatchingMessageRecentActions(
|
export function getMatchingMessageRecentActions(
|
||||||
pluginData: PluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
message: SavedMessage,
|
message: SavedMessage,
|
||||||
type: RecentActionType,
|
type: RecentActionType,
|
||||||
identifier: string,
|
identifier: string,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { RecentActionType } from "../constants";
|
import { RecentActionType } from "../constants";
|
||||||
|
|
||||||
export function getMatchingRecentActions(
|
export function getMatchingRecentActions(
|
||||||
pluginData: PluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
type: RecentActionType,
|
type: RecentActionType,
|
||||||
identifier: string | null,
|
identifier: string | null,
|
||||||
since: number,
|
since: number,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { MatchableTextType } from "./matchMultipleTextTypesOnMessage";
|
import { MatchableTextType } from "./matchMultipleTextTypesOnMessage";
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { messageSummary, verboseChannelMention } from "../../../utils";
|
import { messageSummary, verboseChannelMention } from "../../../utils";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { User } from "eris";
|
import { User } from "eris";
|
||||||
|
|
||||||
export function getTextMatchPartialSummary(
|
export function getTextMatchPartialSummary(
|
||||||
pluginData: PluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
type: MatchableTextType,
|
type: MatchableTextType,
|
||||||
context: AutomodContext,
|
context: AutomodContext,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { MINUTES } from "../../../utils";
|
import { MINUTES } from "../../../utils";
|
||||||
|
|
||||||
const IGNORED_ROLE_CHANGE_LIFETIME = 5 * MINUTES;
|
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;
|
const cutoff = Date.now() - IGNORED_ROLE_CHANGE_LIFETIME;
|
||||||
for (const ignoredChange of pluginData.state.ignoredRoleChanges.values()) {
|
for (const ignoredChange of pluginData.state.ignoredRoleChanges.values()) {
|
||||||
if (ignoredChange.timestamp < cutoff) {
|
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({
|
pluginData.state.ignoredRoleChanges.add({
|
||||||
memberId,
|
memberId,
|
||||||
roleId,
|
roleId,
|
||||||
|
@ -26,7 +26,11 @@ export function ignoreRoleChange(pluginData: PluginData<AutomodPluginType>, memb
|
||||||
/**
|
/**
|
||||||
* @return Whether the role change should be ignored
|
* @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()) {
|
for (const ignoredChange of pluginData.state.ignoredRoleChanges.values()) {
|
||||||
if (ignoredChange.memberId === memberId && ignoredChange.roleId === roleId) {
|
if (ignoredChange.memberId === memberId && ignoredChange.roleId === roleId) {
|
||||||
pluginData.state.ignoredRoleChanges.delete(ignoredChange);
|
pluginData.state.ignoredRoleChanges.delete(ignoredChange);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { resolveMember } from "../../../utils";
|
import { resolveMember } from "../../../utils";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
|
|
||||||
type TextTriggerWithMultipleMatchTypes = {
|
type TextTriggerWithMultipleMatchTypes = {
|
||||||
|
@ -20,7 +20,7 @@ type YieldedContent = [MatchableTextType, string];
|
||||||
* Generator function that allows iterating through matchable pieces of text of a SavedMessage
|
* Generator function that allows iterating through matchable pieces of text of a SavedMessage
|
||||||
*/
|
*/
|
||||||
export async function* matchMultipleTextTypesOnMessage(
|
export async function* matchMultipleTextTypesOnMessage(
|
||||||
pluginData: PluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
trigger: TextTriggerWithMultipleMatchTypes,
|
trigger: TextTriggerWithMultipleMatchTypes,
|
||||||
msg: SavedMessage,
|
msg: SavedMessage,
|
||||||
): AsyncIterableIterator<YieldedContent> {
|
): AsyncIterableIterator<YieldedContent> {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
|
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
|
||||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
||||||
import { TextChannel } from "eris";
|
import { TextChannel } from "eris";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
|
|
||||||
export function resolveActionContactMethods(
|
export function resolveActionContactMethods(
|
||||||
pluginData: PluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
actionConfig: {
|
actionConfig: {
|
||||||
notify?: string;
|
notify?: string;
|
||||||
notifyChannel?: string;
|
notifyChannel?: string;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodContext, AutomodPluginType } from "../types";
|
import { AutomodContext, AutomodPluginType } from "../types";
|
||||||
import { availableTriggers } from "../triggers/availableTriggers";
|
import { availableTriggers } from "../triggers/availableTriggers";
|
||||||
import { availableActions } from "../actions/availableActions";
|
import { availableActions } from "../actions/availableActions";
|
||||||
|
@ -6,7 +6,7 @@ import { AutomodTriggerMatchResult } from "../helpers";
|
||||||
import { CleanAction } from "../actions/clean";
|
import { CleanAction } from "../actions/clean";
|
||||||
import { checkAndUpdateCooldown } from "./checkAndUpdateCooldown";
|
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 userId = context.user?.id || context.member?.id || context.message?.user_id;
|
||||||
const user = context.user || (userId && pluginData.client.users.get(userId));
|
const user = context.user || (userId && pluginData.client.users.get(userId));
|
||||||
const member = context.member || (userId && pluginData.guild.members.get(userId));
|
const member = context.member || (userId && pluginData.guild.members.get(userId));
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { User } from "eris";
|
import { User } from "eris";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodPluginType } from "../types";
|
import { AutomodPluginType } from "../types";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
import { LogType } from "../../../data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { stripObjectToScalars } from "../../../utils";
|
import { stripObjectToScalars } from "../../../utils";
|
||||||
|
|
||||||
export async function setAntiraidLevel(
|
export async function setAntiraidLevel(
|
||||||
pluginData: PluginData<AutomodPluginType>,
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
newLevel: string | null,
|
newLevel: string | null,
|
||||||
user?: User,
|
user?: User,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { Awaitable } from "knub/dist/utils";
|
import { Awaitable } from "knub/dist/utils";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { AutomodContext, AutomodPluginType } from "./types";
|
import { AutomodContext, AutomodPluginType } from "./types";
|
||||||
|
@ -15,14 +15,14 @@ export interface AutomodTriggerMatchResult<TExtra extends any = unknown> {
|
||||||
|
|
||||||
type AutomodTriggerMatchFn<TConfigType, TMatchResultExtra> = (meta: {
|
type AutomodTriggerMatchFn<TConfigType, TMatchResultExtra> = (meta: {
|
||||||
ruleName: string;
|
ruleName: string;
|
||||||
pluginData: PluginData<AutomodPluginType>;
|
pluginData: GuildPluginData<AutomodPluginType>;
|
||||||
context: AutomodContext;
|
context: AutomodContext;
|
||||||
triggerConfig: TConfigType;
|
triggerConfig: TConfigType;
|
||||||
}) => Awaitable<null | AutomodTriggerMatchResult<TMatchResultExtra>>;
|
}) => Awaitable<null | AutomodTriggerMatchResult<TMatchResultExtra>>;
|
||||||
|
|
||||||
type AutomodTriggerRenderMatchInformationFn<TConfigType, TMatchResultExtra> = (meta: {
|
type AutomodTriggerRenderMatchInformationFn<TConfigType, TMatchResultExtra> = (meta: {
|
||||||
ruleName: string;
|
ruleName: string;
|
||||||
pluginData: PluginData<AutomodPluginType>;
|
pluginData: GuildPluginData<AutomodPluginType>;
|
||||||
contexts: AutomodContext[];
|
contexts: AutomodContext[];
|
||||||
triggerConfig: TConfigType;
|
triggerConfig: TConfigType;
|
||||||
matchResult: AutomodTriggerMatchResult<TMatchResultExtra>;
|
matchResult: AutomodTriggerMatchResult<TMatchResultExtra>;
|
||||||
|
@ -54,7 +54,7 @@ export function automodTrigger(...args) {
|
||||||
|
|
||||||
type AutomodActionApplyFn<TConfigType> = (meta: {
|
type AutomodActionApplyFn<TConfigType> = (meta: {
|
||||||
ruleName: string;
|
ruleName: string;
|
||||||
pluginData: PluginData<AutomodPluginType>;
|
pluginData: GuildPluginData<AutomodPluginType>;
|
||||||
contexts: AutomodContext[];
|
contexts: AutomodContext[];
|
||||||
actionConfig: TConfigType;
|
actionConfig: TConfigType;
|
||||||
matchResult: AutomodTriggerMatchResult;
|
matchResult: AutomodTriggerMatchResult;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ZeppelinPluginBlueprint } from "../ZeppelinPluginBlueprint";
|
import { ZeppelinGuildPluginBlueprint } from "../ZeppelinPluginBlueprint";
|
||||||
import { trimPluginDescription } from "../../utils";
|
import { trimPluginDescription } from "../../utils";
|
||||||
|
|
||||||
export const pluginInfo: ZeppelinPluginBlueprint["info"] = {
|
export const pluginInfo: ZeppelinGuildPluginBlueprint["info"] = {
|
||||||
prettyName: "Automod",
|
prettyName: "Automod",
|
||||||
description: trimPluginDescription(`
|
description: trimPluginDescription(`
|
||||||
Allows specifying automated actions in response to triggers. Example use cases include word filtering and spam prevention.
|
Allows specifying automated actions in response to triggers. Example use cases include word filtering and spam prevention.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { BotControlPluginType, ConfigSchema } from "./types";
|
import { BotControlPluginType, ConfigSchema } from "./types";
|
||||||
import { GuildArchives } from "../../data/GuildArchives";
|
import { GuildArchives } from "../../data/GuildArchives";
|
||||||
import { TextChannel } from "eris";
|
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,
|
configSchema: ConfigSchema,
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { command } from "knub";
|
import { botControlCmd } from "../types";
|
||||||
import { BotControlPluginType } from "../types";
|
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
|
|
||||||
export const LeaveServerCmd = command<BotControlPluginType>()({
|
export const LeaveServerCmd = botControlCmd({
|
||||||
trigger: ["leave_server", "leave_guild"],
|
trigger: ["leave_server", "leave_guild"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { command } from "knub";
|
import { botControlCmd } from "../types";
|
||||||
import { BotControlPluginType } from "../types";
|
|
||||||
import { isOwnerPreFilter } from "../../../pluginUtils";
|
import { isOwnerPreFilter } from "../../../pluginUtils";
|
||||||
import { getActiveReload, setActiveReload } from "../activeReload";
|
import { getActiveReload, setActiveReload } from "../activeReload";
|
||||||
import { TextChannel } from "eris";
|
import { TextChannel } from "eris";
|
||||||
|
|
||||||
export const ReloadGlobalPluginsCmd = command<BotControlPluginType>()({
|
export const ReloadGlobalPluginsCmd = botControlCmd({
|
||||||
trigger: "bot_reload_global_plugins",
|
trigger: "bot_reload_global_plugins",
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { command } from "knub";
|
import { botControlCmd } from "../types";
|
||||||
import { BotControlPluginType } from "../types";
|
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
|
|
||||||
export const ReloadServerCmd = command<BotControlPluginType>()({
|
export const ReloadServerCmd = botControlCmd({
|
||||||
trigger: ["reload_server", "reload_guild"],
|
trigger: ["reload_server", "reload_guild"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { command } from "knub";
|
import { botControlCmd } from "../types";
|
||||||
import { BotControlPluginType } from "../types";
|
|
||||||
import { isOwnerPreFilter } from "../../../pluginUtils";
|
import { isOwnerPreFilter } from "../../../pluginUtils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import escapeStringRegexp from "escape-string-regexp";
|
import escapeStringRegexp from "escape-string-regexp";
|
||||||
import { createChunkedMessage, getUser, sorter } from "../../../utils";
|
import { createChunkedMessage, getUser, sorter } from "../../../utils";
|
||||||
|
|
||||||
export const ServersCmd = command<BotControlPluginType>()({
|
export const ServersCmd = botControlCmd({
|
||||||
trigger: ["servers", "guilds"],
|
trigger: ["servers", "guilds"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { tNullable } from "../../utils";
|
import { tNullable } from "../../utils";
|
||||||
import { BasePluginType } from "knub";
|
import { BasePluginType, globalCommand, globalEventListener } from "knub";
|
||||||
import { GuildArchives } from "../../data/GuildArchives";
|
import { GuildArchives } from "../../data/GuildArchives";
|
||||||
|
|
||||||
export const ConfigSchema = t.type({
|
export const ConfigSchema = t.type({
|
||||||
|
@ -15,3 +15,6 @@ export interface BotControlPluginType extends BasePluginType {
|
||||||
archives: GuildArchives;
|
archives: GuildArchives;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const botControlCmd = globalCommand<BotControlPluginType>();
|
||||||
|
export const botControlEvt = globalEventListener<BotControlPluginType>();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { CaseArgs, CaseNoteArgs, CasesPluginType, ConfigSchema } from "./types";
|
import { CaseArgs, CaseNoteArgs, CasesPluginType, ConfigSchema } from "./types";
|
||||||
import { createCase } from "./functions/createCase";
|
import { createCase } from "./functions/createCase";
|
||||||
import { GuildLogs } from "../../data/GuildLogs";
|
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,
|
showInDocs: true,
|
||||||
info: {
|
info: {
|
||||||
prettyName: "Cases",
|
prettyName: "Cases",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { CaseArgs, CasesPluginType } from "../types";
|
import { CaseArgs, CasesPluginType } from "../types";
|
||||||
import { resolveUser } from "../../../utils";
|
import { resolveUser } from "../../../utils";
|
||||||
import { plugin, PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { createCaseNote } from "./createCaseNote";
|
import { createCaseNote } from "./createCaseNote";
|
||||||
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
|
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
|
||||||
import { logger } from "../../../logger";
|
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 user = await resolveUser(pluginData.client, args.userId);
|
||||||
const userName = `${user.username}#${user.discriminator}`;
|
const userName = `${user.username}#${user.discriminator}`;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { CaseNoteArgs, CasesPluginType } from "../types";
|
import { CaseNoteArgs, CasesPluginType } from "../types";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
||||||
import { resolveCaseId } from "./resolveCaseId";
|
import { resolveCaseId } from "./resolveCaseId";
|
||||||
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
|
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
|
||||||
import { resolveUser } from "../../../utils";
|
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));
|
const theCase = await pluginData.state.cases.find(resolveCaseId(args.caseId));
|
||||||
if (!theCase) {
|
if (!theCase) {
|
||||||
throw new RecoverablePluginError(ERRORS.UNKNOWN_NOTE_CASE);
|
throw new RecoverablePluginError(ERRORS.UNKNOWN_NOTE_CASE);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
|
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
|
||||||
import { caseColors } from "../caseColors";
|
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];
|
return pluginData.config.get().case_colors?.[CaseTypeToName[caseType]] ?? caseColors[caseType];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Case } from "../../../data/entities/Case";
|
||||||
import { AdvancedMessageContent, MessageContent } from "eris";
|
import { AdvancedMessageContent, MessageContent } from "eris";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes";
|
import { CaseTypes } from "../../../data/CaseTypes";
|
||||||
import { PluginData, helpers } from "knub";
|
import { GuildPluginData, helpers } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import { resolveCaseId } from "./resolveCaseId";
|
import { resolveCaseId } from "./resolveCaseId";
|
||||||
import { chunkLines, chunkMessageLines, emptyEmbedValue, messageLink } from "../../../utils";
|
import { chunkLines, chunkMessageLines, emptyEmbedValue, messageLink } from "../../../utils";
|
||||||
|
@ -10,7 +10,7 @@ import { getCaseColor } from "./getCaseColor";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||||
|
|
||||||
export async function getCaseEmbed(
|
export async function getCaseEmbed(
|
||||||
pluginData: PluginData<CasesPluginType>,
|
pluginData: GuildPluginData<CasesPluginType>,
|
||||||
caseOrCaseId: Case | number,
|
caseOrCaseId: Case | number,
|
||||||
requestMemberId?: string,
|
requestMemberId?: string,
|
||||||
): Promise<AdvancedMessageContent> {
|
): Promise<AdvancedMessageContent> {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
|
import { CaseTypes, CaseTypeToName } from "../../../data/CaseTypes";
|
||||||
import { caseIcons } from "../caseIcons";
|
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];
|
return pluginData.config.get().case_icons?.[CaseTypeToName[caseType]] ?? caseIcons[caseType];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import {
|
import {
|
||||||
convertDelayStringToMS,
|
convertDelayStringToMS,
|
||||||
|
@ -24,7 +24,7 @@ const UPDATE_STR = "**[Update]**";
|
||||||
const RELATIVE_TIME_THRESHOLD = 7 * DAYS;
|
const RELATIVE_TIME_THRESHOLD = 7 * DAYS;
|
||||||
|
|
||||||
export async function getCaseSummary(
|
export async function getCaseSummary(
|
||||||
pluginData: PluginData<CasesPluginType>,
|
pluginData: GuildPluginData<CasesPluginType>,
|
||||||
caseOrCaseId: Case | number,
|
caseOrCaseId: Case | number,
|
||||||
withLinks = false,
|
withLinks = false,
|
||||||
requestMemberId?: string,
|
requestMemberId?: string,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes";
|
import { CaseTypes } from "../../../data/CaseTypes";
|
||||||
|
|
||||||
export async function getCaseTypeAmountForUserId(
|
export async function getCaseTypeAmountForUserId(
|
||||||
pluginData: PluginData<CasesPluginType>,
|
pluginData: GuildPluginData<CasesPluginType>,
|
||||||
userID: string,
|
userID: string,
|
||||||
type: CaseTypes,
|
type: CaseTypes,
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import { Message, MessageContent, MessageFile, TextChannel } from "eris";
|
import { Message, MessageContent, MessageFile, TextChannel } from "eris";
|
||||||
import { isDiscordRESTError } from "../../../utils";
|
import { isDiscordRESTError } from "../../../utils";
|
||||||
|
@ -9,7 +9,7 @@ import { resolveCaseId } from "./resolveCaseId";
|
||||||
import { logger } from "../../../logger";
|
import { logger } from "../../../logger";
|
||||||
|
|
||||||
export async function postToCaseLogChannel(
|
export async function postToCaseLogChannel(
|
||||||
pluginData: PluginData<CasesPluginType>,
|
pluginData: GuildPluginData<CasesPluginType>,
|
||||||
content: MessageContent,
|
content: MessageContent,
|
||||||
file: MessageFile = null,
|
file: MessageFile = null,
|
||||||
): Promise<Message | null> {
|
): Promise<Message | null> {
|
||||||
|
@ -40,7 +40,7 @@ export async function postToCaseLogChannel(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function postCaseToCaseLogChannel(
|
export async function postCaseToCaseLogChannel(
|
||||||
pluginData: PluginData<CasesPluginType>,
|
pluginData: GuildPluginData<CasesPluginType>,
|
||||||
caseOrCaseId: Case | number,
|
caseOrCaseId: Case | number,
|
||||||
): Promise<Message | null> {
|
): Promise<Message | null> {
|
||||||
const theCase = await pluginData.state.cases.find(resolveCaseId(caseOrCaseId));
|
const theCase = await pluginData.state.cases.find(resolveCaseId(caseOrCaseId));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { tDelayString, tPartialDictionary, tNullable } from "../../utils";
|
import { tDelayString, tPartialDictionary, tNullable } from "../../utils";
|
||||||
import { CaseNameToType, CaseTypes } from "../../data/CaseTypes";
|
import { CaseNameToType, CaseTypes } from "../../data/CaseTypes";
|
||||||
import { BasePluginType } from "knub";
|
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||||
import { GuildLogs } from "../../data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildCases } from "../../data/GuildCases";
|
import { GuildCases } from "../../data/GuildCases";
|
||||||
import { GuildArchives } from "../../data/GuildArchives";
|
import { GuildArchives } from "../../data/GuildArchives";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { PluginOptions } from "knub";
|
import { PluginOptions } from "knub";
|
||||||
import { ConfigSchema, CensorPluginType } from "./types";
|
import { ConfigSchema, CensorPluginType } from "./types";
|
||||||
import { GuildLogs } from "src/data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
import { onMessageCreate } from "./util/onMessageCreate";
|
import { onMessageCreate } from "./util/onMessageCreate";
|
||||||
import { onMessageUpdate } from "./util/onMessageUpdate";
|
import { onMessageUpdate } from "./util/onMessageUpdate";
|
||||||
import { trimPluginDescription } from "../../utils";
|
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,
|
showInDocs: true,
|
||||||
info: {
|
info: {
|
||||||
prettyName: "Censor",
|
prettyName: "Censor",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { BasePluginType, eventListener } from "knub";
|
import { BasePluginType } from "knub";
|
||||||
import { tNullable } from "src/utils";
|
import { tNullable } from "../../utils";
|
||||||
import { TRegex } from "src/validatorUtils";
|
import { TRegex } from "../../validatorUtils";
|
||||||
import { GuildLogs } from "src/data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
import { RegExpRunner } from "../../RegExpRunner";
|
import { RegExpRunner } from "../../RegExpRunner";
|
||||||
|
|
||||||
export const ConfigSchema = t.type({
|
export const ConfigSchema = t.type({
|
||||||
|
@ -35,5 +35,3 @@ export interface CensorPluginType extends BasePluginType {
|
||||||
onMessageUpdateFn;
|
onMessageUpdateFn;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const censorEvent = eventListener<CensorPluginType>();
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CensorPluginType } from "../types";
|
import { CensorPluginType } from "../types";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { AnyInvite, Embed, GuildInvite } from "eris";
|
import { AnyInvite, Embed, GuildInvite } from "eris";
|
||||||
import { ZalgoRegex } from "src/data/Zalgo";
|
import { ZalgoRegex } from "../../../data/Zalgo";
|
||||||
import {
|
import {
|
||||||
getInviteCodesInString,
|
getInviteCodesInString,
|
||||||
getUrlsInString,
|
getUrlsInString,
|
||||||
|
@ -10,15 +10,15 @@ import {
|
||||||
resolveInvite,
|
resolveInvite,
|
||||||
isGuildInvite,
|
isGuildInvite,
|
||||||
isRESTGuildInvite,
|
isRESTGuildInvite,
|
||||||
} from "src/utils";
|
} from "../../../utils";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import { censorMessage } from "./censorMessage";
|
import { censorMessage } from "./censorMessage";
|
||||||
import escapeStringRegexp from "escape-string-regexp";
|
import escapeStringRegexp from "escape-string-regexp";
|
||||||
import { logger } from "src/logger";
|
import { logger } from "../../../logger";
|
||||||
import { allowTimeout } from "../../../RegExpRunner";
|
import { allowTimeout } from "../../../RegExpRunner";
|
||||||
|
|
||||||
export async function applyFiltersToMsg(
|
export async function applyFiltersToMsg(
|
||||||
pluginData: PluginData<CensorPluginType>,
|
pluginData: GuildPluginData<CensorPluginType>,
|
||||||
savedMessage: SavedMessage,
|
savedMessage: SavedMessage,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const member = await resolveMember(pluginData.client, pluginData.guild, savedMessage.user_id);
|
const member = await resolveMember(pluginData.client, pluginData.guild, savedMessage.user_id);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CensorPluginType } from "../types";
|
import { CensorPluginType } from "../types";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { LogType } from "src/data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { stripObjectToScalars, resolveUser } from "src/utils";
|
import { stripObjectToScalars, resolveUser } from "../../../utils";
|
||||||
import { disableCodeBlocks, deactivateMentions } from "knub/dist/helpers";
|
import { disableCodeBlocks, deactivateMentions } from "knub/dist/helpers";
|
||||||
|
|
||||||
export async function censorMessage(
|
export async function censorMessage(
|
||||||
pluginData: PluginData<CensorPluginType>,
|
pluginData: GuildPluginData<CensorPluginType>,
|
||||||
savedMessage: SavedMessage,
|
savedMessage: SavedMessage,
|
||||||
reason: string,
|
reason: string,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CensorPluginType } from "../types";
|
import { CensorPluginType } from "../types";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { applyFiltersToMsg } from "./applyFiltersToMsg";
|
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;
|
if (savedMessage.is_bot) return;
|
||||||
const lock = await pluginData.locks.acquire(`message-${savedMessage.id}`);
|
const lock = await pluginData.locks.acquire(`message-${savedMessage.id}`);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CensorPluginType } from "../types";
|
import { CensorPluginType } from "../types";
|
||||||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||||
import { applyFiltersToMsg } from "./applyFiltersToMsg";
|
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;
|
if (savedMessage.is_bot) return;
|
||||||
const lock = await pluginData.locks.acquire(`message-${savedMessage.id}`);
|
const lock = await pluginData.locks.acquire(`message-${savedMessage.id}`);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { ChannelArchiverPluginType } from "./types";
|
import { ChannelArchiverPluginType } from "./types";
|
||||||
import { ArchiveChannelCmd } from "./commands/ArchiveChannelCmd";
|
import { ArchiveChannelCmd } from "./commands/ArchiveChannelCmd";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
|
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
|
||||||
|
|
||||||
export const ChannelArchiverPlugin = zeppelinPlugin<ChannelArchiverPluginType>()("channel_archiver", {
|
export const ChannelArchiverPlugin = zeppelinGuildPlugin<ChannelArchiverPluginType>()("channel_archiver", {
|
||||||
showInDocs: false,
|
showInDocs: false,
|
||||||
|
|
||||||
dependencies: [TimeAndDatePlugin],
|
dependencies: [TimeAndDatePlugin],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { channelArchiverCmd } from "../types";
|
import { channelArchiverCmd } from "../types";
|
||||||
import { isOwner, sendErrorMessage } from "src/pluginUtils";
|
import { isOwner, sendErrorMessage } from "../../../pluginUtils";
|
||||||
import { confirm, SECONDS, noop } from "src/utils";
|
import { confirm, SECONDS, noop } from "../../../utils";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { rehostAttachment } from "../rehostAttachment";
|
import { rehostAttachment } from "../rehostAttachment";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Attachment, TextChannel } from "eris";
|
import { Attachment, TextChannel } from "eris";
|
||||||
import { downloadFile } from "src/utils";
|
import { downloadFile } from "../../utils";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
const fsp = fs.promises;
|
const fsp = fs.promises;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { BasePluginType, command } from "knub";
|
import { BasePluginType, guildCommand } from "knub";
|
||||||
|
|
||||||
export interface ChannelArchiverPluginType extends BasePluginType {
|
export interface ChannelArchiverPluginType extends BasePluginType {
|
||||||
state: {};
|
state: {};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const channelArchiverCmd = command<ChannelArchiverPluginType>();
|
export const channelArchiverCmd = guildCommand<ChannelArchiverPluginType>();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { CompanionChannelsPluginType, ConfigSchema, TCompanionChannelOpts } from "./types";
|
import { CompanionChannelsPluginType, ConfigSchema, TCompanionChannelOpts } from "./types";
|
||||||
import { VoiceChannelJoinEvt } from "./events/VoiceChannelJoinEvt";
|
import { VoiceChannelJoinEvt } from "./events/VoiceChannelJoinEvt";
|
||||||
import { VoiceChannelSwitchEvt } from "./events/VoiceChannelSwitchEvt";
|
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,
|
showInDocs: true,
|
||||||
info: {
|
info: {
|
||||||
prettyName: "Companion channels",
|
prettyName: "Companion channels",
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { eventListener } from "knub";
|
import { companionChannelsEvt } from "../types";
|
||||||
import { CompanionChannelsPluginType } from "../types";
|
|
||||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||||
import { stripObjectToScalars } from "src/utils";
|
import { stripObjectToScalars } from "../../../utils";
|
||||||
|
|
||||||
export const VoiceChannelJoinEvt = eventListener<CompanionChannelsPluginType>()(
|
export const VoiceChannelJoinEvt = companionChannelsEvt(
|
||||||
"voiceChannelJoin",
|
"voiceChannelJoin",
|
||||||
({ pluginData, args: { member, newChannel } }) => {
|
({ pluginData, args: { member, newChannel } }) => {
|
||||||
handleCompanionPermissions(pluginData, member.id, newChannel);
|
handleCompanionPermissions(pluginData, member.id, newChannel);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { eventListener } from "knub";
|
import { companionChannelsEvt } from "../types";
|
||||||
import { CompanionChannelsPluginType } from "../types";
|
|
||||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||||
|
|
||||||
export const VoiceChannelLeaveEvt = eventListener<CompanionChannelsPluginType>()(
|
export const VoiceChannelLeaveEvt = companionChannelsEvt(
|
||||||
"voiceChannelLeave",
|
"voiceChannelLeave",
|
||||||
({ pluginData, args: { member, oldChannel } }) => {
|
({ pluginData, args: { member, oldChannel } }) => {
|
||||||
handleCompanionPermissions(pluginData, member.id, null, oldChannel);
|
handleCompanionPermissions(pluginData, member.id, null, oldChannel);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { eventListener } from "knub";
|
import { companionChannelsEvt } from "../types";
|
||||||
import { CompanionChannelsPluginType } from "../types";
|
|
||||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||||
|
|
||||||
export const VoiceChannelSwitchEvt = eventListener<CompanionChannelsPluginType>()(
|
export const VoiceChannelSwitchEvt = companionChannelsEvt(
|
||||||
"voiceChannelSwitch",
|
"voiceChannelSwitch",
|
||||||
({ pluginData, args: { member, oldChannel, newChannel } }) => {
|
({ pluginData, args: { member, oldChannel, newChannel } }) => {
|
||||||
handleCompanionPermissions(pluginData, member.id, newChannel, oldChannel);
|
handleCompanionPermissions(pluginData, member.id, newChannel, oldChannel);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { VoiceChannel } from "eris";
|
import { VoiceChannel } from "eris";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
|
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
|
||||||
|
|
||||||
const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
||||||
|
@ -7,7 +7,7 @@ const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getCompanionChannelOptsForVoiceChannelId(
|
export function getCompanionChannelOptsForVoiceChannelId(
|
||||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||||
userId: string,
|
userId: string,
|
||||||
voiceChannel: VoiceChannel,
|
voiceChannel: VoiceChannel,
|
||||||
): TCompanionChannelOpts[] {
|
): TCompanionChannelOpts[] {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
|
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
|
||||||
import { getCompanionChannelOptsForVoiceChannelId } from "./getCompanionChannelOptsForVoiceChannelId";
|
import { getCompanionChannelOptsForVoiceChannelId } from "./getCompanionChannelOptsForVoiceChannelId";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { TextChannel, VoiceChannel } from "eris";
|
import { TextChannel, VoiceChannel } from "eris";
|
||||||
import { isDiscordRESTError, MINUTES } from "../../../utils";
|
import { isDiscordRESTError, MINUTES } from "../../../utils";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
|
@ -10,19 +10,19 @@ const ERROR_COOLDOWN_KEY = "errorCooldown";
|
||||||
const ERROR_COOLDOWN = 5 * MINUTES;
|
const ERROR_COOLDOWN = 5 * MINUTES;
|
||||||
|
|
||||||
export async function handleCompanionPermissions(
|
export async function handleCompanionPermissions(
|
||||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||||
userId: string,
|
userId: string,
|
||||||
voiceChannel: VoiceChannel,
|
voiceChannel: VoiceChannel,
|
||||||
oldChannel?: VoiceChannel,
|
oldChannel?: VoiceChannel,
|
||||||
);
|
);
|
||||||
export async function handleCompanionPermissions(
|
export async function handleCompanionPermissions(
|
||||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||||
userId: string,
|
userId: string,
|
||||||
voiceChannel: null,
|
voiceChannel: null,
|
||||||
oldChannel: VoiceChannel,
|
oldChannel: VoiceChannel,
|
||||||
);
|
);
|
||||||
export async function handleCompanionPermissions(
|
export async function handleCompanionPermissions(
|
||||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||||
userId: string,
|
userId: string,
|
||||||
voiceChannel?: VoiceChannel,
|
voiceChannel?: VoiceChannel,
|
||||||
oldChannel?: VoiceChannel,
|
oldChannel?: VoiceChannel,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { tNullable } from "../../utils";
|
import { tNullable } from "../../utils";
|
||||||
import { BasePluginType, CooldownManager } from "knub";
|
import { BasePluginType, CooldownManager, guildEventListener } from "knub";
|
||||||
import { GuildLogs } from "../../data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
|
|
||||||
|
@ -28,3 +28,5 @@ export interface CompanionChannelsPluginType extends BasePluginType {
|
||||||
errorCooldownManager: CooldownManager;
|
errorCooldownManager: CooldownManager;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const companionChannelsEvt = guildEventListener<CompanionChannelsPluginType>();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { ConfigSchema, CustomEventsPluginType } from "./types";
|
import { ConfigSchema, CustomEventsPluginType } from "./types";
|
||||||
import { command, parseSignature } from "knub";
|
import { guildCommand, parseSignature } from "knub";
|
||||||
import { commandTypes } from "../../commandTypes";
|
import { commandTypes } from "../../commandTypes";
|
||||||
import { stripObjectToScalars } from "../../utils";
|
import { stripObjectToScalars } from "../../utils";
|
||||||
import { runEvent } from "./functions/runEvent";
|
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,
|
showInDocs: false,
|
||||||
|
|
||||||
configSchema: ConfigSchema,
|
configSchema: ConfigSchema,
|
||||||
|
@ -22,7 +22,7 @@ export const CustomEventsPlugin = zeppelinPlugin<CustomEventsPluginType>()("cust
|
||||||
for (const [key, event] of Object.entries(config.events)) {
|
for (const [key, event] of Object.entries(config.events)) {
|
||||||
if (event.trigger.type === "command") {
|
if (event.trigger.type === "command") {
|
||||||
const signature = event.trigger.params ? parseSignature(event.trigger.params, commandTypes) : {};
|
const signature = event.trigger.params ? parseSignature(event.trigger.params, commandTypes) : {};
|
||||||
const eventCommand = command({
|
const eventCommand = guildCommand({
|
||||||
trigger: event.trigger.name,
|
trigger: event.trigger.name,
|
||||||
permission: `events.${key}.trigger.can_use`,
|
permission: `events.${key}.trigger.can_use`,
|
||||||
signature,
|
signature,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { renderTemplate } from "../../../templateFormatter";
|
import { renderTemplate } from "../../../templateFormatter";
|
||||||
|
@ -15,7 +15,7 @@ export const AddRoleAction = t.type({
|
||||||
export type TAddRoleAction = t.TypeOf<typeof AddRoleAction>;
|
export type TAddRoleAction = t.TypeOf<typeof AddRoleAction>;
|
||||||
|
|
||||||
export async function addRoleAction(
|
export async function addRoleAction(
|
||||||
pluginData: PluginData<CustomEventsPluginType>,
|
pluginData: GuildPluginData<CustomEventsPluginType>,
|
||||||
action: TAddRoleAction,
|
action: TAddRoleAction,
|
||||||
values: any,
|
values: any,
|
||||||
event: TCustomEvent,
|
event: TCustomEvent,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { renderTemplate } from "../../../templateFormatter";
|
import { renderTemplate } from "../../../templateFormatter";
|
||||||
|
@ -16,7 +16,7 @@ export const CreateCaseAction = t.type({
|
||||||
export type TCreateCaseAction = t.TypeOf<typeof CreateCaseAction>;
|
export type TCreateCaseAction = t.TypeOf<typeof CreateCaseAction>;
|
||||||
|
|
||||||
export async function createCaseAction(
|
export async function createCaseAction(
|
||||||
pluginData: PluginData<CustomEventsPluginType>,
|
pluginData: GuildPluginData<CustomEventsPluginType>,
|
||||||
action: TCreateCaseAction,
|
action: TCreateCaseAction,
|
||||||
values: any,
|
values: any,
|
||||||
event: TCustomEvent,
|
event: TCustomEvent,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CustomEventsPluginType } from "../types";
|
import { CustomEventsPluginType } from "../types";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { renderTemplate } from "../../../templateFormatter";
|
import { renderTemplate } from "../../../templateFormatter";
|
||||||
|
@ -13,7 +13,7 @@ export const MessageAction = t.type({
|
||||||
export type TMessageAction = t.TypeOf<typeof MessageAction>;
|
export type TMessageAction = t.TypeOf<typeof MessageAction>;
|
||||||
|
|
||||||
export async function messageAction(
|
export async function messageAction(
|
||||||
pluginData: PluginData<CustomEventsPluginType>,
|
pluginData: GuildPluginData<CustomEventsPluginType>,
|
||||||
action: TMessageAction,
|
action: TMessageAction,
|
||||||
values: any,
|
values: any,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { renderTemplate } from "../../../templateFormatter";
|
import { renderTemplate } from "../../../templateFormatter";
|
||||||
|
@ -15,7 +15,7 @@ export const MoveToVoiceChannelAction = t.type({
|
||||||
export type TMoveToVoiceChannelAction = t.TypeOf<typeof MoveToVoiceChannelAction>;
|
export type TMoveToVoiceChannelAction = t.TypeOf<typeof MoveToVoiceChannelAction>;
|
||||||
|
|
||||||
export async function moveToVoiceChannelAction(
|
export async function moveToVoiceChannelAction(
|
||||||
pluginData: PluginData<CustomEventsPluginType>,
|
pluginData: GuildPluginData<CustomEventsPluginType>,
|
||||||
action: TMoveToVoiceChannelAction,
|
action: TMoveToVoiceChannelAction,
|
||||||
values: any,
|
values: any,
|
||||||
event: TCustomEvent,
|
event: TCustomEvent,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
import { CustomEventsPluginType, TCustomEvent } from "../types";
|
||||||
import { sendErrorMessage } from "../../../pluginUtils";
|
import { sendErrorMessage } from "../../../pluginUtils";
|
||||||
import { ActionError } from "../ActionError";
|
import { ActionError } from "../ActionError";
|
||||||
|
@ -9,7 +9,7 @@ import { moveToVoiceChannelAction } from "../actions/moveToVoiceChannelAction";
|
||||||
import { messageAction } from "../actions/messageAction";
|
import { messageAction } from "../actions/messageAction";
|
||||||
|
|
||||||
export async function runEvent(
|
export async function runEvent(
|
||||||
pluginData: PluginData<CustomEventsPluginType>,
|
pluginData: GuildPluginData<CustomEventsPluginType>,
|
||||||
event: TCustomEvent,
|
event: TCustomEvent,
|
||||||
eventData: any,
|
eventData: any,
|
||||||
values: any,
|
values: any,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { BasePluginType, eventListener, PluginData } from "knub";
|
import { BasePluginType, globalEventListener, GlobalPluginData } from "knub";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||||
import { Guild } from "eris";
|
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))) {
|
if (!(await pluginData.state.allowedGuilds.isAllowed(guild.id))) {
|
||||||
console.log(`Non-allowed server ${guild.name} (${guild.id}), leaving`);
|
console.log(`Non-allowed server ${guild.name} (${guild.id}), leaving`);
|
||||||
guild.leave();
|
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
|
* 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({}),
|
configSchema: t.type({}),
|
||||||
|
|
||||||
events: [
|
events: [
|
||||||
eventListener<GuildAccessMonitorPluginType>()("guildAvailable", ({ pluginData, args: { guild } }) => {
|
globalEventListener<GuildAccessMonitorPluginType>()("guildAvailable", ({ pluginData, args: { guild } }) => {
|
||||||
checkGuild(pluginData, guild);
|
checkGuild(pluginData, guild);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { GuildConfigReloaderPluginType } from "./types";
|
import { GuildConfigReloaderPluginType } from "./types";
|
||||||
import { Configs } from "../../data/Configs";
|
import { Configs } from "../../data/Configs";
|
||||||
import { reloadChangedGuilds } from "./functions/reloadChangedGuilds";
|
import { reloadChangedGuilds } from "./functions/reloadChangedGuilds";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
|
|
||||||
export const GuildConfigReloaderPlugin = zeppelinPlugin<GuildConfigReloaderPluginType>()("guild_config_reloader", {
|
export const GuildConfigReloaderPlugin = zeppelinGlobalPlugin<GuildConfigReloaderPluginType>()(
|
||||||
|
"guild_config_reloader",
|
||||||
|
{
|
||||||
showInDocs: false,
|
showInDocs: false,
|
||||||
|
|
||||||
configSchema: t.type({}),
|
configSchema: t.type({}),
|
||||||
|
@ -20,4 +22,5 @@ export const GuildConfigReloaderPlugin = zeppelinPlugin<GuildConfigReloaderPlugi
|
||||||
clearTimeout(pluginData.state.nextCheckTimeout);
|
clearTimeout(pluginData.state.nextCheckTimeout);
|
||||||
pluginData.state.unloaded = true;
|
pluginData.state.unloaded = true;
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { PluginData } from "knub";
|
import { GlobalPluginData } from "knub";
|
||||||
import { GuildConfigReloaderPluginType } from "../types";
|
import { GuildConfigReloaderPluginType } from "../types";
|
||||||
import { SECONDS } from "../../../utils";
|
import { SECONDS } from "../../../utils";
|
||||||
|
|
||||||
const CHECK_INTERVAL = 1 * SECONDS;
|
const CHECK_INTERVAL = 1 * SECONDS;
|
||||||
|
|
||||||
export async function reloadChangedGuilds(pluginData: PluginData<GuildConfigReloaderPluginType>) {
|
export async function reloadChangedGuilds(pluginData: GlobalPluginData<GuildConfigReloaderPluginType>) {
|
||||||
if (pluginData.state.unloaded) return;
|
if (pluginData.state.unloaded) return;
|
||||||
|
|
||||||
const changedConfigs = await pluginData.state.guildConfigs.getActiveLargerThanId(pluginData.state.highestConfigId);
|
const changedConfigs = await pluginData.state.guildConfigs.getActiveLargerThanId(pluginData.state.highestConfigId);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AllowedGuilds } from "src/data/AllowedGuilds";
|
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||||
import { GuildInfoSaverPluginType } from "./types";
|
import { GuildInfoSaverPluginType } from "./types";
|
||||||
import { MINUTES } from "src/utils";
|
import { MINUTES } from "../../utils";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
|
|
||||||
export const GuildInfoSaverPlugin = zeppelinPlugin<GuildInfoSaverPluginType>()("guild_info_saver", {
|
export const GuildInfoSaverPlugin = zeppelinGuildPlugin<GuildInfoSaverPluginType>()("guild_info_saver", {
|
||||||
showInDocs: false,
|
showInDocs: false,
|
||||||
|
|
||||||
configSchema: t.type({}),
|
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.state.allowedGuilds.updateInfo(
|
||||||
pluginData.guild.id,
|
pluginData.guild.id,
|
||||||
pluginData.guild.name,
|
pluginData.guild.name,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BasePluginType } from "knub";
|
import { BasePluginType } from "knub";
|
||||||
import { AllowedGuilds } from "src/data/AllowedGuilds";
|
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||||
|
|
||||||
export interface GuildInfoSaverPluginType extends BasePluginType {
|
export interface GuildInfoSaverPluginType extends BasePluginType {
|
||||||
state: {
|
state: {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { PluginOptions } from "knub";
|
import { PluginOptions } from "knub";
|
||||||
import { ConfigSchema, LocateUserPluginType } from "./types";
|
import { ConfigSchema, LocateUserPluginType } from "./types";
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { GuildVCAlerts } from "src/data/GuildVCAlerts";
|
import { GuildVCAlerts } from "../../data/GuildVCAlerts";
|
||||||
import { outdatedAlertsLoop } from "./utils/outdatedLoop";
|
import { outdatedAlertsLoop } from "./utils/outdatedLoop";
|
||||||
import { fillActiveAlertsList } from "./utils/fillAlertsList";
|
import { fillActiveAlertsList } from "./utils/fillAlertsList";
|
||||||
import { WhereCmd } from "./commands/WhereCmd";
|
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,
|
showInDocs: true,
|
||||||
info: {
|
info: {
|
||||||
prettyName: "Locate user",
|
prettyName: "Locate user",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { locateUserCommand } from "../types";
|
import { locateUserCmd } from "../types";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import humanizeDuration from "humanize-duration";
|
import humanizeDuration from "humanize-duration";
|
||||||
import { MINUTES, SECONDS } from "src/utils";
|
import { MINUTES, SECONDS } from "../../../utils";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
|
|
||||||
export const FollowCmd = locateUserCommand({
|
export const FollowCmd = locateUserCmd({
|
||||||
trigger: ["follow", "f"],
|
trigger: ["follow", "f"],
|
||||||
description: "Sets up an alert that notifies you any time `<member>` switches or joins voice channels",
|
description: "Sets up an alert that notifies you any time `<member>` switches or joins voice channels",
|
||||||
usage: "!f 108552944961454080",
|
usage: "!f 108552944961454080",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { locateUserCommand } from "../types";
|
import { locateUserCmd } from "../types";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
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"],
|
trigger: ["follows", "fs"],
|
||||||
description: "Displays all of your active alerts ordered by expiration time",
|
description: "Displays all of your active alerts ordered by expiration time",
|
||||||
usage: "!fs",
|
usage: "!fs",
|
||||||
|
@ -29,7 +29,7 @@ export const ListFollowCmd = locateUserCommand({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DeleteFollowCmd = locateUserCommand({
|
export const DeleteFollowCmd = locateUserCmd({
|
||||||
trigger: ["follows delete", "fs d"],
|
trigger: ["follows delete", "fs d"],
|
||||||
description:
|
description:
|
||||||
"Deletes the alert at the position <num>.\nThe value needed for <num> can be found using `!follows` (`!fs`)",
|
"Deletes the alert at the position <num>.\nThe value needed for <num> can be found using `!follows` (`!fs`)",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { locateUserCommand } from "../types";
|
import { locateUserCmd } from "../types";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { resolveMember } from "src/utils";
|
import { resolveMember } from "../../../utils";
|
||||||
import { sendWhere } from "../utils/sendWhere";
|
import { sendWhere } from "../utils/sendWhere";
|
||||||
|
|
||||||
export const WhereCmd = locateUserCommand({
|
export const WhereCmd = locateUserCmd({
|
||||||
trigger: ["where", "w"],
|
trigger: ["where", "w"],
|
||||||
description: "Posts an instant invite to the voice channel that `<member>` is in",
|
description: "Posts an instant invite to the voice channel that `<member>` is in",
|
||||||
usage: "!w 108552944961454080",
|
usage: "!w 108552944961454080",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { locateUserEvent } from "../types";
|
import { locateUserEvt } from "../types";
|
||||||
|
|
||||||
export const GuildBanRemoveAlertsEvt = locateUserEvent({
|
export const GuildBanRemoveAlertsEvt = locateUserEvt({
|
||||||
event: "guildBanAdd",
|
event: "guildBanAdd",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { locateUserEvent } from "../types";
|
import { locateUserEvt } from "../types";
|
||||||
import { sendAlerts } from "../utils/sendAlerts";
|
import { sendAlerts } from "../utils/sendAlerts";
|
||||||
import { TextableChannel, VoiceChannel } from "eris";
|
import { TextableChannel, VoiceChannel } from "eris";
|
||||||
|
|
||||||
export const ChannelJoinAlertsEvt = locateUserEvent({
|
export const ChannelJoinAlertsEvt = locateUserEvt({
|
||||||
event: "voiceChannelJoin",
|
event: "voiceChannelJoin",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
@ -12,7 +12,7 @@ export const ChannelJoinAlertsEvt = locateUserEvent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ChannelSwitchAlertsEvt = locateUserEvent({
|
export const ChannelSwitchAlertsEvt = locateUserEvt({
|
||||||
event: "voiceChannelSwitch",
|
event: "voiceChannelSwitch",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
@ -22,7 +22,7 @@ export const ChannelSwitchAlertsEvt = locateUserEvent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ChannelLeaveAlertsEvt = locateUserEvent({
|
export const ChannelLeaveAlertsEvt = locateUserEvt({
|
||||||
event: "voiceChannelLeave",
|
event: "voiceChannelLeave",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import * as t from "io-ts";
|
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({
|
export const ConfigSchema = t.type({
|
||||||
can_where: t.boolean,
|
can_where: t.boolean,
|
||||||
|
@ -9,7 +11,13 @@ export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||||
|
|
||||||
export interface LocateUserPluginType extends BasePluginType {
|
export interface LocateUserPluginType extends BasePluginType {
|
||||||
config: TConfigSchema;
|
config: TConfigSchema;
|
||||||
|
state: {
|
||||||
|
alerts: GuildVCAlerts;
|
||||||
|
outdatedAlertsTimeout: Timeout;
|
||||||
|
usersWithAlerts: string[];
|
||||||
|
unloaded: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const locateUserCommand = command<LocateUserPluginType>();
|
export const locateUserCmd = guildCommand<LocateUserPluginType>();
|
||||||
export const locateUserEvent = eventListener<LocateUserPluginType>();
|
export const locateUserEvt = guildEventListener<LocateUserPluginType>();
|
||||||
|
|
|
@ -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();
|
const allAlerts = await pluginData.state.alerts.getAllGuildAlerts();
|
||||||
|
|
||||||
allAlerts.forEach(alert => {
|
allAlerts.forEach(alert => {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Member, TextableChannel } from "eris";
|
import { Member, TextableChannel } from "eris";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { LocateUserPluginType } from "../types";
|
import { LocateUserPluginType } from "../types";
|
||||||
import { sendErrorMessage } from "src/pluginUtils";
|
import { sendErrorMessage } from "../../../pluginUtils";
|
||||||
|
|
||||||
export async function moveMember(
|
export async function moveMember(
|
||||||
pluginData: PluginData<LocateUserPluginType>,
|
pluginData: GuildPluginData<LocateUserPluginType>,
|
||||||
toMoveID: string,
|
toMoveID: string,
|
||||||
target: Member,
|
target: Member,
|
||||||
errorChannel: TextableChannel,
|
errorChannel: TextableChannel,
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { SECONDS } from "src/utils";
|
import { SECONDS } from "../../../utils";
|
||||||
import { removeUserIdFromActiveAlerts } from "./removeUserIdFromActiveAlerts";
|
import { removeUserIdFromActiveAlerts } from "./removeUserIdFromActiveAlerts";
|
||||||
|
import { GuildPluginData } from "knub";
|
||||||
|
import { LocateUserPluginType } from "../types";
|
||||||
|
|
||||||
const ALERT_LOOP_TIME = 30 * SECONDS;
|
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();
|
const outdatedAlerts = await pluginData.state.alerts.getOutdatedAlerts();
|
||||||
|
|
||||||
for (const alert of outdatedAlerts) {
|
for (const alert of outdatedAlerts) {
|
||||||
|
|
|
@ -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);
|
const index = pluginData.state.usersWithAlerts.indexOf(userId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
pluginData.state.usersWithAlerts.splice(index, 1);
|
pluginData.state.usersWithAlerts.splice(index, 1);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { LocateUserPluginType } from "../types";
|
import { LocateUserPluginType } from "../types";
|
||||||
import { resolveMember } from "src/utils";
|
import { resolveMember } from "../../../utils";
|
||||||
import { sendWhere } from "./sendWhere";
|
import { sendWhere } from "./sendWhere";
|
||||||
import { TextableChannel } from "eris";
|
import { TextableChannel } from "eris";
|
||||||
import { moveMember } from "./moveMember";
|
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 triggeredAlerts = await pluginData.state.alerts.getAlertsByUserId(userId);
|
||||||
const member = await resolveMember(pluginData.client, pluginData.guild, userId);
|
const member = await resolveMember(pluginData.client, pluginData.guild, userId);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { Member, TextableChannel, VoiceChannel } from "eris";
|
import { Member, TextableChannel, VoiceChannel } from "eris";
|
||||||
import { getInviteLink } from "knub/dist/helpers";
|
import { getInviteLink } from "knub/dist/helpers";
|
||||||
import { createOrReuseInvite } from "./createOrReuseInvite";
|
import { createOrReuseInvite } from "./createOrReuseInvite";
|
||||||
import { PluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { LocateUserPluginType } from "../types";
|
import { LocateUserPluginType } from "../types";
|
||||||
import { sendErrorMessage } from "../../../pluginUtils";
|
import { sendErrorMessage } from "../../../pluginUtils";
|
||||||
|
|
||||||
export async function sendWhere(
|
export async function sendWhere(
|
||||||
pluginData: PluginData<LocateUserPluginType>,
|
pluginData: GuildPluginData<LocateUserPluginType>,
|
||||||
member: Member,
|
member: Member,
|
||||||
channel: TextableChannel,
|
channel: TextableChannel,
|
||||||
prepend: string,
|
prepend: string,
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||||
import { PluginOptions } from "knub";
|
import { PluginOptions } from "knub";
|
||||||
import { ConfigSchema, LogsPluginType } from "./types";
|
import { ConfigSchema, LogsPluginType } from "./types";
|
||||||
import DefaultLogMessages from "../../data/DefaultLogMessages.json";
|
import DefaultLogMessages from "../../data/DefaultLogMessages.json";
|
||||||
import { GuildLogs } from "src/data/GuildLogs";
|
import { GuildLogs } from "../../data/GuildLogs";
|
||||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||||
import { GuildArchives } from "src/data/GuildArchives";
|
import { GuildArchives } from "../../data/GuildArchives";
|
||||||
import { GuildCases } from "src/data/GuildCases";
|
import { GuildCases } from "../../data/GuildCases";
|
||||||
import { onMessageDelete } from "./util/onMessageDelete";
|
import { onMessageDelete } from "./util/onMessageDelete";
|
||||||
import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk";
|
import { onMessageDeleteBulk } from "./util/onMessageDeleteBulk";
|
||||||
import { onMessageUpdate } from "./util/onMessageUpdate";
|
import { onMessageUpdate } from "./util/onMessageUpdate";
|
||||||
import { LogsGuildMemberAddEvt } from "./events/LogsGuildMemberAddEvt";
|
import { LogsGuildMemberAddEvt } from "./events/LogsGuildMemberAddEvt";
|
||||||
import { LogsGuildMemberRemoveEvt } from "./events/LogsGuildMemberRemoveEvt";
|
import { LogsGuildMemberRemoveEvt } from "./events/LogsGuildMemberRemoveEvt";
|
||||||
import { LogsGuildMemberUpdateEvt, LogsUserUpdateEvt } from "./events/LogsUserUpdateEvts";
|
import { LogsGuildMemberUpdateEvt } from "./events/LogsUserUpdateEvts";
|
||||||
import { LogsChannelCreateEvt, LogsChannelDeleteEvt } from "./events/LogsChannelModifyEvts";
|
import { LogsChannelCreateEvt, LogsChannelDeleteEvt } from "./events/LogsChannelModifyEvts";
|
||||||
import { LogsRoleCreateEvt, LogsRoleDeleteEvt } from "./events/LogsRoleModifyEvts";
|
import { LogsRoleCreateEvt, LogsRoleDeleteEvt } from "./events/LogsRoleModifyEvts";
|
||||||
import { LogsVoiceJoinEvt, LogsVoiceLeaveEvt, LogsVoiceSwitchEvt } from "./events/LogsVoiceChannelEvts";
|
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,
|
showInDocs: true,
|
||||||
info: {
|
info: {
|
||||||
prettyName: "Logs",
|
prettyName: "Logs",
|
||||||
|
@ -58,7 +58,6 @@ export const LogsPlugin = zeppelinPlugin<LogsPluginType>()("logs", {
|
||||||
LogsGuildMemberAddEvt,
|
LogsGuildMemberAddEvt,
|
||||||
LogsGuildMemberRemoveEvt,
|
LogsGuildMemberRemoveEvt,
|
||||||
LogsGuildMemberUpdateEvt,
|
LogsGuildMemberUpdateEvt,
|
||||||
LogsUserUpdateEvt,
|
|
||||||
LogsChannelCreateEvt,
|
LogsChannelCreateEvt,
|
||||||
LogsChannelDeleteEvt,
|
LogsChannelDeleteEvt,
|
||||||
LogsRoleCreateEvt,
|
LogsRoleCreateEvt,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { logsEvent } from "../types";
|
import { logsEvt } from "../types";
|
||||||
import { stripObjectToScalars } from "src/utils";
|
import { stripObjectToScalars } from "../../../utils";
|
||||||
import { LogType } from "src/data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
|
|
||||||
export const LogsChannelCreateEvt = logsEvent({
|
export const LogsChannelCreateEvt = logsEvt({
|
||||||
event: "channelCreate",
|
event: "channelCreate",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
@ -12,7 +12,7 @@ export const LogsChannelCreateEvt = logsEvent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const LogsChannelDeleteEvt = logsEvent({
|
export const LogsChannelDeleteEvt = logsEvt({
|
||||||
event: "channelDelete",
|
event: "channelDelete",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { logsEvent } from "../types";
|
import { logsEvt } from "../types";
|
||||||
import { stripObjectToScalars, UnknownUser } from "src/utils";
|
import { stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||||
import { LogType } from "src/data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
import { Constants as ErisConstants } from "eris";
|
import { Constants as ErisConstants } from "eris";
|
||||||
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
||||||
|
|
||||||
export const LogsGuildBanAddEvt = logsEvent({
|
export const LogsGuildBanAddEvt = logsEvt({
|
||||||
event: "guildBanAdd",
|
event: "guildBanAdd",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
@ -29,7 +29,7 @@ export const LogsGuildBanAddEvt = logsEvent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const LogsGuildBanRemoveEvt = logsEvent({
|
export const LogsGuildBanRemoveEvt = logsEvt({
|
||||||
event: "guildBanRemove",
|
event: "guildBanRemove",
|
||||||
|
|
||||||
async listener(meta) {
|
async listener(meta) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue