mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +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
|
@ -1,4 +1,4 @@
|
|||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { CasesPlugin } from "../Cases/CasesPlugin";
|
||||
import { MutesPlugin } from "../Mutes/MutesPlugin";
|
||||
import { BanOptions, ConfigSchema, KickOptions, ModActionsPluginType, WarnOptions } from "./types";
|
||||
|
@ -24,9 +24,9 @@ import { CasesUserCmd } from "./commands/CasesUserCmd";
|
|||
import { CasesModCmd } from "./commands/CasesModCmd";
|
||||
import { HideCaseCmd } from "./commands/HideCaseCmd";
|
||||
import { UnhideCaseCmd } from "./commands/UnhideCaseCmd";
|
||||
import { GuildMutes } from "src/data/GuildMutes";
|
||||
import { GuildCases } from "src/data/GuildCases";
|
||||
import { GuildLogs } from "src/data/GuildLogs";
|
||||
import { GuildMutes } from "../../data/GuildMutes";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { ForceUnmuteCmd } from "./commands/ForceunmuteCmd";
|
||||
import { warnMember } from "./functions/warnMember";
|
||||
import { Member } from "eris";
|
||||
|
@ -95,7 +95,7 @@ const defaultOptions = {
|
|||
],
|
||||
};
|
||||
|
||||
export const ModActionsPlugin = zeppelinPlugin<ModActionsPluginType>()("mod_actions", {
|
||||
export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()("mod_actions", {
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Mod actions",
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage, hasPermission, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, resolveMember, stripObjectToScalars } from "../../../utils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { CaseTypes } from "src/data/CaseTypes";
|
||||
import { CasesPlugin } from "src/plugins/Cases/CasesPlugin";
|
||||
import { Case } from "src/data/entities/Case";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
};
|
||||
|
||||
export const AddCaseCmd = modActionsCommand({
|
||||
export const AddCaseCmd = modActionsCmd({
|
||||
trigger: "addcase",
|
||||
permission: "can_addcase",
|
||||
description: "Add an arbitrary case to the specified user without taking any action",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand, IgnoredEventType } from "../types";
|
||||
import { modActionsCmd, IgnoredEventType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage, hasPermission, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, resolveMember } from "../../../utils";
|
||||
|
@ -7,7 +7,7 @@ import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromA
|
|||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { banUserId } from "../functions/banUserId";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -16,7 +16,7 @@ const opts = {
|
|||
"delete-days": ct.number({ option: true, shortcut: "d" }),
|
||||
};
|
||||
|
||||
export const BanCmd = modActionsCommand({
|
||||
export const BanCmd = modActionsCmd({
|
||||
trigger: "ban",
|
||||
permission: "can_ban",
|
||||
description: "Ban the specified member",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { CasesPlugin } from "src/plugins/Cases/CasesPlugin";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
|
||||
export const CaseCmd = modActionsCommand({
|
||||
export const CaseCmd = modActionsCmd({
|
||||
trigger: "case",
|
||||
permission: "can_view",
|
||||
description: "Show information about a specific case",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { trimLines, createChunkedMessage, emptyEmbedValue, sorter } from "src/utils";
|
||||
import { trimLines, createChunkedMessage, emptyEmbedValue, sorter } from "../../../utils";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { asyncMap } from "../../../utils/async";
|
||||
import { EmbedOptions } from "eris";
|
||||
|
@ -13,7 +13,7 @@ const opts = {
|
|||
mod: ct.member({ option: true }),
|
||||
};
|
||||
|
||||
export const CasesModCmd = modActionsCommand({
|
||||
export const CasesModCmd = modActionsCmd({
|
||||
trigger: "cases",
|
||||
permission: "can_view",
|
||||
description: "Show the most recent 5 cases by the specified -mod",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { CasesPlugin } from "src/plugins/Cases/CasesPlugin";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import {
|
||||
UnknownUser,
|
||||
multiSorter,
|
||||
|
@ -10,7 +10,7 @@ import {
|
|||
resolveUser,
|
||||
emptyEmbedValue,
|
||||
chunkArray,
|
||||
} from "src/utils";
|
||||
} from "../../../utils";
|
||||
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
|
||||
import { EmbedOptions, User } from "eris";
|
||||
import { getChunkedEmbedFields } from "../../../utils/getChunkedEmbedFields";
|
||||
|
@ -21,7 +21,7 @@ const opts = {
|
|||
hidden: ct.bool({ option: true, isSwitch: true, shortcut: "h" }),
|
||||
};
|
||||
|
||||
export const CasesUserCmd = modActionsCommand({
|
||||
export const CasesUserCmd = modActionsCmd({
|
||||
trigger: "cases",
|
||||
permission: "can_view",
|
||||
description: "Show a list of cases the specified user has",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { helpers } from "knub";
|
||||
|
@ -10,7 +10,7 @@ import { LogType } from "../../../data/LogType";
|
|||
import moment from "moment-timezone";
|
||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||
|
||||
export const DeleteCaseCmd = modActionsCommand({
|
||||
export const DeleteCaseCmd = modActionsCmd({
|
||||
trigger: ["delete_case", "deletecase"],
|
||||
permission: "can_deletecase",
|
||||
description: trimLines(`
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand, IgnoredEventType } from "../types";
|
||||
import { modActionsCmd, IgnoredEventType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage, hasPermission, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, resolveMember, stripObjectToScalars } from "../../../utils";
|
||||
|
@ -7,15 +7,15 @@ import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromA
|
|||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { banUserId } from "../functions/banUserId";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { CaseTypes } from "src/data/CaseTypes";
|
||||
import { CasesPlugin } from "src/plugins/Cases/CasesPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
};
|
||||
|
||||
export const ForcebanCmd = modActionsCommand({
|
||||
export const ForcebanCmd = modActionsCmd({
|
||||
trigger: "forceban",
|
||||
permission: "can_ban",
|
||||
description: "Force-ban the specified user, even if they aren't on the server",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../utils";
|
||||
|
@ -10,7 +10,7 @@ const opts = {
|
|||
"notify-channel": ct.textChannel({ option: true }),
|
||||
};
|
||||
|
||||
export const ForcemuteCmd = modActionsCommand({
|
||||
export const ForcemuteCmd = modActionsCmd({
|
||||
trigger: "forcemute",
|
||||
permission: "can_mute",
|
||||
description: "Force-mute the specified user, even if they're not on the server",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, resolveMember } from "../../../utils";
|
||||
|
@ -8,7 +8,7 @@ const opts = {
|
|||
mod: ct.member({ option: true }),
|
||||
};
|
||||
|
||||
export const ForceUnmuteCmd = modActionsCommand({
|
||||
export const ForceUnmuteCmd = modActionsCmd({
|
||||
trigger: "forceunmute",
|
||||
permission: "can_mute",
|
||||
description: "Force-unmute the specified user, even if they're not on the server",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
export const HideCaseCmd = modActionsCommand({
|
||||
export const HideCaseCmd = modActionsCmd({
|
||||
trigger: ["hide", "hidecase", "hide_case"],
|
||||
permission: "can_hidecase",
|
||||
description: "Hide the specified case so it doesn't appear in !cases or !info",
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, resolveMember } from "../../../utils";
|
||||
import { MutesPlugin } from "src/plugins/Mutes/MutesPlugin";
|
||||
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "../functions/actualUnmuteUserCmd";
|
||||
import { isBanned } from "../functions/isBanned";
|
||||
import { plugin } from "knub";
|
||||
import { actualKickMemberCmd } from "../functions/actualKickMemberCmd";
|
||||
|
||||
const opts = {
|
||||
|
@ -15,7 +14,7 @@ const opts = {
|
|||
clean: ct.bool({ option: true, isSwitch: true }),
|
||||
};
|
||||
|
||||
export const KickCmd = modActionsCommand({
|
||||
export const KickCmd = modActionsCmd({
|
||||
trigger: "kick",
|
||||
permission: "can_kick",
|
||||
description: "Kick the specified member",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand, IgnoredEventType } from "../types";
|
||||
import { modActionsCmd, IgnoredEventType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage, hasPermission, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, resolveMember, stripObjectToScalars } from "../../../utils";
|
||||
|
@ -6,14 +6,14 @@ import { isBanned } from "../functions/isBanned";
|
|||
import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromArgs";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { banUserId } from "../functions/banUserId";
|
||||
import { CaseTypes } from "src/data/CaseTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { TextChannel } from "eris";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { CasesPlugin } from "src/plugins/Cases/CasesPlugin";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
||||
export const MassbanCmd = modActionsCommand({
|
||||
export const MassbanCmd = modActionsCmd({
|
||||
trigger: "massban",
|
||||
permission: "can_massban",
|
||||
description: "Mass-ban a list of user IDs",
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { stripObjectToScalars } from "../../../utils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { TextChannel } from "eris";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { logger } from "src/logger";
|
||||
import { MutesPlugin } from "src/plugins/Mutes/MutesPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
|
||||
|
||||
export const MassmuteCmd = modActionsCommand({
|
||||
export const MassmuteCmd = modActionsCmd({
|
||||
trigger: "massmute",
|
||||
permission: "can_massmute",
|
||||
description: "Mass-mute a list of user IDs",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { canActOn, hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
@ -20,7 +20,7 @@ const opts = {
|
|||
"notify-channel": ct.textChannel({ option: true }),
|
||||
};
|
||||
|
||||
export const MuteCmd = modActionsCommand({
|
||||
export const MuteCmd = modActionsCmd({
|
||||
trigger: "mute",
|
||||
permission: "can_mute",
|
||||
description: "Mute the specified member",
|
||||
|
@ -49,7 +49,7 @@ export const MuteCmd = modActionsCommand({
|
|||
|
||||
if (!memberToMute) {
|
||||
const _isBanned = await isBanned(pluginData, user.id);
|
||||
const prefix = pluginData.guildConfig.prefix;
|
||||
const prefix = pluginData.fullConfig.prefix;
|
||||
if (_isBanned) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
@ -8,7 +8,7 @@ import { LogType } from "../../../data/LogType";
|
|||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
|
||||
export const NoteCmd = modActionsCommand({
|
||||
export const NoteCmd = modActionsCmd({
|
||||
trigger: "note",
|
||||
permission: "can_note",
|
||||
description: "Add a note to the specified user",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { trimPluginDescription } from "../../../utils";
|
||||
import { actualKickMemberCmd } from "../functions/actualKickMemberCmd";
|
||||
|
@ -9,7 +9,7 @@ const opts = {
|
|||
"notify-channel": ct.textChannel({ option: true }),
|
||||
};
|
||||
|
||||
export const SoftbanCmd = modActionsCommand({
|
||||
export const SoftbanCmd = modActionsCmd({
|
||||
trigger: "softban",
|
||||
permission: "can_kick",
|
||||
description: trimPluginDescription(`
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import { modActionsCommand, IgnoredEventType } from "../types";
|
||||
import { modActionsCmd, IgnoredEventType } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, hasPermission, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||
import { CaseTypes } from "src/data/CaseTypes";
|
||||
import { CasesPlugin } from "src/plugins/Cases/CasesPlugin";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
};
|
||||
|
||||
export const UnbanCmd = modActionsCommand({
|
||||
export const UnbanCmd = modActionsCmd({
|
||||
trigger: "unban",
|
||||
permission: "can_ban",
|
||||
description: "Unban the specified member",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
export const UnhideCaseCmd = modActionsCommand({
|
||||
export const UnhideCaseCmd = modActionsCmd({
|
||||
trigger: ["unhide", "unhidecase", "unhide_case"],
|
||||
permission: "can_hidecase",
|
||||
description: "Un-hide the specified case, making it appear in !cases and !info again",
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { resolveUser, resolveMember } from "../../../utils";
|
||||
import { MutesPlugin } from "src/plugins/Mutes/MutesPlugin";
|
||||
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "../functions/actualUnmuteUserCmd";
|
||||
import { isBanned } from "../functions/isBanned";
|
||||
import { plugin } from "knub";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
};
|
||||
|
||||
export const UnmuteCmd = modActionsCommand({
|
||||
export const UnmuteCmd = modActionsCmd({
|
||||
trigger: "unmute",
|
||||
permission: "can_mute",
|
||||
description: "Unmute the specified member",
|
||||
|
@ -48,7 +47,7 @@ export const UnmuteCmd = modActionsCommand({
|
|||
|
||||
if (!memberToUnmute) {
|
||||
const banned = await isBanned(pluginData, user.id);
|
||||
const prefix = pluginData.guildConfig.prefix;
|
||||
const prefix = pluginData.fullConfig.prefix;
|
||||
if (banned) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
@ -7,7 +7,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
|
|||
import { LogType } from "../../../data/LogType";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
||||
export const UpdateCmd = modActionsCommand({
|
||||
export const UpdateCmd = modActionsCmd({
|
||||
trigger: "update",
|
||||
permission: "can_note",
|
||||
description:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { canActOn, hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
@ -13,7 +13,7 @@ import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromA
|
|||
import { warnMember } from "../functions/warnMember";
|
||||
import { TextChannel } from "eris";
|
||||
|
||||
export const WarnCmd = modActionsCommand({
|
||||
export const WarnCmd = modActionsCmd({
|
||||
trigger: "warn",
|
||||
permission: "can_warn",
|
||||
description: "Send a warning to the specified user",
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import { eventListener } from "knub";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
import { IgnoredEventType, modActionsEvt } from "../types";
|
||||
import { isEventIgnored } from "../functions/isEventIgnored";
|
||||
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
|
||||
import { Constants as ErisConstants } from "eris";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { stripObjectToScalars, resolveUser } from "src/utils";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { stripObjectToScalars, resolveUser } from "../../../utils";
|
||||
|
||||
/**
|
||||
* Create a BAN case automatically when a user is banned manually.
|
||||
* Attempts to find the ban's details in the audit log.
|
||||
*/
|
||||
export const CreateBanCaseOnManualBanEvt = eventListener<ModActionsPluginType>()(
|
||||
export const CreateBanCaseOnManualBanEvt = modActionsEvt(
|
||||
"guildBanAdd",
|
||||
async ({ pluginData, args: { guild, user } }) => {
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Ban, user.id)) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { eventListener } from "knub";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
import { IgnoredEventType, modActionsEvt } from "../types";
|
||||
import { isEventIgnored } from "../functions/isEventIgnored";
|
||||
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
|
||||
import { Constants as ErisConstants } from "eris";
|
||||
|
@ -14,7 +13,7 @@ import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAu
|
|||
* Create a KICK case automatically when a user is kicked manually.
|
||||
* Attempts to find the kick's details in the audit log.
|
||||
*/
|
||||
export const CreateKickCaseOnManualKickEvt = eventListener<ModActionsPluginType>()(
|
||||
export const CreateKickCaseOnManualKickEvt = modActionsEvt(
|
||||
"guildMemberRemove",
|
||||
async ({ pluginData, args: { member } }) => {
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Kick, member.id)) {
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import { eventListener } from "knub";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
import { IgnoredEventType, modActionsEvt } from "../types";
|
||||
import { isEventIgnored } from "../functions/isEventIgnored";
|
||||
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
|
||||
import { Constants as ErisConstants } from "eris";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
|
||||
import { stripObjectToScalars, resolveUser } from "src/utils";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { stripObjectToScalars, resolveUser } from "../../../utils";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
||||
/**
|
||||
* Create an UNBAN case automatically when a user is unbanned manually.
|
||||
* Attempts to find the unban's details in the audit log.
|
||||
*/
|
||||
export const CreateUnbanCaseOnManualUnbanEvt = eventListener<ModActionsPluginType>()(
|
||||
export const CreateUnbanCaseOnManualUnbanEvt = modActionsEvt(
|
||||
"guildBanRemove",
|
||||
async ({ pluginData, args: { guild, user } }) => {
|
||||
if (isEventIgnored(pluginData, IgnoredEventType.Unban, user.id)) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { eventListener } from "knub";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
import { modActionsEvt } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { TextChannel } from "eris";
|
||||
|
@ -7,7 +6,7 @@ import { TextChannel } from "eris";
|
|||
/**
|
||||
* Show an alert if a member with prior notes joins the server
|
||||
*/
|
||||
export const PostAlertOnMemberJoinEvt = eventListener<ModActionsPluginType>()(
|
||||
export const PostAlertOnMemberJoinEvt = modActionsEvt(
|
||||
"guildMemberAdd",
|
||||
async ({ pluginData, args: { guild, member } }) => {
|
||||
const config = pluginData.config.get();
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Member, TextChannel } from "eris";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
import { errorMessage, resolveUser, resolveMember } from "src/utils";
|
||||
import { PluginData } from "knub";
|
||||
import { sendErrorMessage, canActOn, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { errorMessage, resolveUser, resolveMember } from "../../../utils";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { sendErrorMessage, canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { hasPermission } from "knub/dist/helpers";
|
||||
import { readContactMethodsFromArgs } from "./readContactMethodsFromArgs";
|
||||
import { formatReasonWithAttachments } from "./formatReasonWithAttachments";
|
||||
|
@ -12,7 +12,7 @@ import { ignoreEvent } from "./ignoreEvent";
|
|||
import { isBanned } from "./isBanned";
|
||||
|
||||
export async function actualKickMemberCmd(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
msg,
|
||||
args: {
|
||||
user: string;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Member, Message, TextChannel, User } from "eris";
|
||||
import { asSingleLine, isDiscordRESTError, UnknownUser } from "../../../utils";
|
||||
import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { formatReasonWithAttachments } from "./formatReasonWithAttachments";
|
||||
|
@ -16,7 +16,7 @@ import { logger } from "../../../logger";
|
|||
* The only difference between the two commands is in target member validation.
|
||||
*/
|
||||
export async function actualMuteUserCmd(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
user: User | UnknownUser,
|
||||
msg: Message,
|
||||
args: { time?: number; reason?: string; mod: Member; notify?: string; "notify-channel"?: TextChannel },
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
import { User, Message, Member } from "eris";
|
||||
import { UnknownUser, asSingleLine } from "src/utils";
|
||||
import { sendErrorMessage, sendSuccessMessage, hasPermission } from "src/pluginUtils";
|
||||
import { UnknownUser, asSingleLine } from "../../../utils";
|
||||
import { sendErrorMessage, sendSuccessMessage, hasPermission } from "../../../pluginUtils";
|
||||
import { formatReasonWithAttachments } from "./formatReasonWithAttachments";
|
||||
import { MutesPlugin } from "src/plugins/Mutes/MutesPlugin";
|
||||
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
|
||||
export async function actualUnmuteCmd(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
user: User | UnknownUser,
|
||||
msg: Message,
|
||||
args: { time?: number; reason?: string; mod?: Member },
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { BanOptions, BanResult, IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
import { notifyUser, resolveUser, stripObjectToScalars, ucfirst, UserNotificationResult } from "../../../utils";
|
||||
import { User } from "eris";
|
||||
|
@ -13,7 +13,7 @@ import { CaseTypes } from "../../../data/CaseTypes";
|
|||
* Ban the specified user id, whether or not they're actually on the server at the time. Generates a case.
|
||||
*/
|
||||
export async function banUserId(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
userId: string,
|
||||
reason: string = null,
|
||||
banOptions: BanOptions = {},
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
|
||||
export function clearIgnoredEvents(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
type: IgnoredEventType,
|
||||
userId: string,
|
||||
) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
import { UserNotificationMethod } from "../../../utils";
|
||||
import { TextChannel } from "eris";
|
||||
|
||||
export function getDefaultContactMethods(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
type: "warn" | "kick" | "ban",
|
||||
): UserNotificationMethod[] {
|
||||
const methods: UserNotificationMethod[] = [];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
import { SECONDS } from "../../../utils";
|
||||
import { clearIgnoredEvents } from "./clearIgnoredEvents";
|
||||
|
@ -6,7 +6,7 @@ import { clearIgnoredEvents } from "./clearIgnoredEvents";
|
|||
const DEFAULT_TIMEOUT = 15 * SECONDS;
|
||||
|
||||
export function ignoreEvent(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
type: IgnoredEventType,
|
||||
userId: string,
|
||||
timeout = DEFAULT_TIMEOUT,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
import { isDiscordHTTPError } from "../../../utils";
|
||||
|
||||
export async function isBanned(pluginData: PluginData<ModActionsPluginType>, userId: string): Promise<boolean> {
|
||||
export async function isBanned(pluginData: GuildPluginData<ModActionsPluginType>, userId: string): Promise<boolean> {
|
||||
try {
|
||||
const bans = await pluginData.guild.getBans();
|
||||
return bans.some(b => b.user.id === userId);
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../types";
|
||||
|
||||
export function isEventIgnored(pluginData: PluginData<ModActionsPluginType>, type: IgnoredEventType, userId: string) {
|
||||
export function isEventIgnored(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
type: IgnoredEventType,
|
||||
userId: string,
|
||||
) {
|
||||
return pluginData.state.ignoredEvents.some(info => type === info.type && userId === info.userId);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { IgnoredEventType, KickOptions, KickResult, ModActionsPluginType } from "../types";
|
||||
import { Member } from "eris";
|
||||
import { notifyUser, resolveUser, stripObjectToScalars, ucfirst, UserNotificationResult } from "../../../utils";
|
||||
|
@ -13,7 +13,7 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
|
|||
* Kick the specified server member. Generates a case.
|
||||
*/
|
||||
export async function kickMember(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
member: Member,
|
||||
reason: string = null,
|
||||
kickOptions: KickOptions = {},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ModActionsPluginType, WarnOptions, WarnResult } from "../types";
|
||||
import { Member } from "eris";
|
||||
import { getDefaultContactMethods } from "./getDefaultContactMethods";
|
||||
|
@ -9,7 +9,7 @@ import { CaseTypes } from "../../../data/CaseTypes";
|
|||
import { LogType } from "../../../data/LogType";
|
||||
|
||||
export async function warnMember(
|
||||
pluginData: PluginData<ModActionsPluginType>,
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
member: Member,
|
||||
reason: string,
|
||||
warnOptions: WarnOptions = {},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { tNullable, UserNotificationMethod, UserNotificationResult } from "../../utils";
|
||||
import { BasePluginType, command } from "knub";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { GuildMutes } from "../../data/GuildMutes";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
|
@ -114,4 +114,5 @@ export interface BanOptions {
|
|||
deleteMessageDays?: number;
|
||||
}
|
||||
|
||||
export const modActionsCommand = command<ModActionsPluginType>();
|
||||
export const modActionsCmd = guildCommand<ModActionsPluginType>();
|
||||
export const modActionsEvt = guildEventListener<ModActionsPluginType>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue