mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-08 00:05:01 +00:00
Ran prettier to fix style issues
This commit is contained in:
parent
893a77d562
commit
1f0c7a4349
170 changed files with 396 additions and 453 deletions
|
@ -10,6 +10,7 @@ import { GuildTempbans } from "../../data/GuildTempbans";
|
|||
import { makePublicFn, mapToPublicFn } from "../../pluginUtils";
|
||||
import { MINUTES } from "../../utils";
|
||||
import { CasesPlugin } from "../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
import { MutesPlugin } from "../Mutes/MutesPlugin";
|
||||
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
|
||||
|
@ -72,7 +73,6 @@ import { onModActionsEvent } from "./functions/onModActionsEvent";
|
|||
import { updateCase } from "./functions/updateCase";
|
||||
import { warnMember } from "./functions/warnMember";
|
||||
import { AttachmentLinkReactionType, ModActionsPluginType, modActionsSlashGroup, zModActionsConfig } from "./types";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
|
|
@ -2,8 +2,8 @@ import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
|||
import { CaseTypes } from "../../../../data/CaseTypes";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { actualAddCaseCmd } from "./actualAddCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualAddCaseCmd } from "./actualAddCaseCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -4,9 +4,9 @@ import { CaseTypes } from "../../../../data/CaseTypes";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualAddCaseCmd } from "./actualAddCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualAddCaseCmd } from "./actualAddCaseCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -48,10 +48,7 @@ export const AddCaseSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import { canActOn } from "../../../../pluginUtils";
|
|||
import { UnknownUser, renderUsername, resolveMember } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualAddCaseCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -27,10 +27,7 @@ export async function actualAddCaseCmd(
|
|||
// If the user exists as a guild member, make sure we can act on them first
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
if (member && !canActOn(pluginData, author, member)) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Cannot add case on this user: insufficient permissions"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, "Cannot add case on this user: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,7 +46,7 @@ export async function actualAddCaseCmd(
|
|||
if (user) {
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Case #${theCase.case_number} created for **${renderUsername(user)}**`
|
||||
`Case #${theCase.case_number} created for **${renderUsername(user)}**`,
|
||||
);
|
||||
} else {
|
||||
pluginData.state.common.sendSuccessMessage(context, `Case #${theCase.case_number} created`);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, resolveUser } from "../../../../utils";
|
||||
import { actualBanCmd } from "./actualBanCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualBanCmd } from "./actualBanCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -3,10 +3,10 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualBanCmd } from "./actualBanCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualBanCmd } from "./actualBanCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "time", description: "The duration of the ban", required: false }),
|
||||
|
@ -51,13 +51,7 @@ export const BanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -70,10 +64,7 @@ export const BanSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,14 @@ import { banLock } from "../../../../utils/lockNameHelpers";
|
|||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { banUserId } from "../../functions/banUserId";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import {
|
||||
formatReasonWithAttachments,
|
||||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualBanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -74,10 +77,7 @@ export async function actualBanCmd(
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"User already banned, update cancelled by moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, "User already banned, update cancelled by moderator");
|
||||
lock.unlock();
|
||||
return;
|
||||
}
|
||||
|
@ -123,9 +123,9 @@ export async function actualBanCmd(
|
|||
}
|
||||
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Ban updated to ${time ? "expire in " + humanizeDuration(time) + " from now" : "indefinite"}`,
|
||||
);
|
||||
context,
|
||||
`Ban updated to ${time ? "expire in " + humanizeDuration(time) + " from now" : "indefinite"}`,
|
||||
);
|
||||
lock.unlock();
|
||||
return;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ export async function actualBanCmd(
|
|||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
`Cannot ban: target permission level is equal or higher to yours, ${targetLevel} >= ${ourLevel}`,
|
||||
);
|
||||
);
|
||||
lock.unlock();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualCaseCmd } from "./actualCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualCaseCmd } from "./actualCaseCmd";
|
||||
|
||||
const opts = {
|
||||
show: ct.switchOption({ def: false, shortcut: "sh" }),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualCaseCmd } from "./actualCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { actualCaseCmd } from "./actualCaseCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.boolean({ name: "show", description: "To make the result visible to everyone", required: false }),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.userId({ option: true }),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.user({ name: "user", description: "The user to show cases for", required: false }),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { resolveMember, resolveUser, UnknownUser } from "../../../../utils";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.userId({ option: true }),
|
||||
|
|
|
@ -159,13 +159,7 @@ async function casesModCmd(
|
|||
const totalCases = await casesPlugin.getTotalCasesByMod(modId ?? author.id, casesFilters);
|
||||
|
||||
if (totalCases === 0) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
`No cases by **${modName}**`,
|
||||
undefined,
|
||||
undefined,
|
||||
!show
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, `No cases by **${modName}**`, undefined, undefined, !show);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { trimLines } from "../../../../utils";
|
||||
import { actualDeleteCaseCmd } from "./actualDeleteCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualDeleteCaseCmd } from "./actualDeleteCaseCmd";
|
||||
|
||||
export const DeleteCaseMsgCmd = modActionsMsgCmd({
|
||||
trigger: ["delete_case", "deletecase"],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { actualDeleteCaseCmd } from "./actualDeleteCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { actualDeleteCaseCmd } from "./actualDeleteCaseCmd";
|
||||
|
||||
const opts = [slashOptions.boolean({ name: "force", description: "Whether or not to force delete", required: false })];
|
||||
|
||||
|
|
|
@ -82,15 +82,12 @@ export async function actualDeleteCaseCmd(
|
|||
: "";
|
||||
const amt = validCases.length - cancelled;
|
||||
if (amt === 0) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"All deletions were cancelled, no cases were deleted."
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, "All deletions were cancelled, no cases were deleted.");
|
||||
return;
|
||||
}
|
||||
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`${amt} case${amt === 1 ? " was" : "s were"} deleted!${failedAddendum}`
|
||||
`${amt} case${amt === 1 ? " was" : "s were"} deleted!${failedAddendum}`,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { actualForceBanCmd } from "./actualForceBanCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualForceBanCmd } from "./actualForceBanCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -3,9 +3,9 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualForceBanCmd } from "./actualForceBanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualForceBanCmd } from "./actualForceBanCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -29,13 +29,7 @@ export const ForceBanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -48,10 +42,7 @@ export const ForceBanSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,13 @@ import { LogType } from "../../../../data/LogType";
|
|||
import { DAYS, MINUTES, UnknownUser } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import {
|
||||
formatReasonWithAttachments,
|
||||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualForceBanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { actualMuteCmd } from "../mute/actualMuteCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualMuteCmd } from "../mute/actualMuteCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -3,10 +3,10 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualMuteCmd } from "../mute/actualMuteCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualMuteCmd } from "../mute/actualMuteCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "time", description: "The duration of the mute", required: false }),
|
||||
|
@ -46,13 +46,7 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -66,10 +60,7 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { actualUnmuteCmd } from "../unmute/actualUnmuteCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualUnmuteCmd } from "../unmute/actualUnmuteCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -3,9 +3,9 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualUnmuteCmd } from "../unmute/actualUnmuteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualUnmuteCmd } from "../unmute/actualUnmuteCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "time", description: "The duration of the unmute", required: false }),
|
||||
|
@ -30,13 +30,7 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -50,10 +44,7 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualHideCaseCmd } from "./actualHideCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualHideCaseCmd } from "./actualHideCaseCmd";
|
||||
|
||||
export const HideCaseMsgCmd = modActionsMsgCmd({
|
||||
trigger: ["hide", "hidecase", "hide_case"],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualHideCaseCmd } from "./actualHideCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { actualHideCaseCmd } from "./actualHideCaseCmd";
|
||||
|
||||
export const HideCaseSlashCmd = modActionsSlashCmd({
|
||||
name: "hidecase",
|
||||
|
|
|
@ -30,7 +30,7 @@ export async function actualHideCaseCmd(
|
|||
|
||||
const amt = caseNumbers.length - failed.length;
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`${amt} case${amt === 1 ? " is" : "s are"} now hidden! Use \`unhidecase\` to unhide them.${failedAddendum}`,
|
||||
);
|
||||
context,
|
||||
`${amt} case${amt === 1 ? " is" : "s are"} now hidden! Use \`unhidecase\` to unhide them.${failedAddendum}`,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { hasPermission } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { actualKickCmd } from "./actualKickCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualKickCmd } from "./actualKickCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -3,10 +3,10 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualKickCmd } from "./actualKickCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualKickCmd } from "./actualKickCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -50,13 +50,7 @@ export const KickSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -69,10 +63,7 @@ export const KickSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,15 @@ import { GuildPluginData } from "knub";
|
|||
import { LogType } from "../../../../data/LogType";
|
||||
import { canActOn } from "../../../../pluginUtils";
|
||||
import { DAYS, SECONDS, UnknownUser, UserNotificationMethod, renderUsername, resolveMember } from "../../../../utils";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import {
|
||||
formatReasonWithAttachments,
|
||||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { kickMember } from "../../functions/kickMember";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualKickCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -71,9 +74,7 @@ export async function actualKickCmd(
|
|||
try {
|
||||
await pluginData.guild.bans.remove(memberToKick.id, "kick -clean");
|
||||
} catch {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Failed to unban the user after banning them (-clean)");
|
||||
pluginData.state.common.sendErrorMessage(context, "Failed to unban the user after banning them (-clean)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd";
|
||||
|
||||
export const MassBanMsgCmd = modActionsMsgCmd({
|
||||
trigger: "massban",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -30,13 +30,7 @@ export const MassBanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -7,10 +7,13 @@ import { canActOn, getContextChannel, isContextInteraction, sendContextResponse
|
|||
import { DAYS, MINUTES, SECONDS, noop } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import {
|
||||
formatReasonWithAttachments,
|
||||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualMassBanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -37,9 +40,7 @@ export async function actualMassBanCmd(
|
|||
for (const userId of userIds) {
|
||||
const member = pluginData.guild.members.cache.get(userId as Snowflake); // TODO: Get members on demand?
|
||||
if (member && !canActOn(pluginData, author, member)) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Cannot massban one or more users: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(context, "Cannot massban one or more users: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -157,14 +158,14 @@ export async function actualMassBanCmd(
|
|||
if (failedBans.length) {
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Banned ${successfulBanCount} users in ${formattedTimeTaken}, ${
|
||||
failedBans.length
|
||||
} failed: ${failedBans.join(" ")}`,
|
||||
`Banned ${successfulBanCount} users in ${formattedTimeTaken}, ${failedBans.length} failed: ${failedBans.join(
|
||||
" ",
|
||||
)}`,
|
||||
);
|
||||
} else {
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Banned ${successfulBanCount} users successfully in ${formattedTimeTaken}`
|
||||
`Banned ${successfulBanCount} users successfully in ${formattedTimeTaken}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd";
|
||||
|
||||
export const MassMuteMsgCmd = modActionsMsgCmd({
|
||||
trigger: "massmute",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -30,13 +30,7 @@ export const MassMuteSlashSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@ import { logger } from "../../../../logger";
|
|||
import { canActOn, isContextInteraction, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import {
|
||||
formatReasonWithAttachments,
|
||||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualMassMuteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -34,10 +37,7 @@ export async function actualMassMuteCmd(
|
|||
for (const userId of userIds) {
|
||||
const member = pluginData.guild.members.cache.get(userId as Snowflake);
|
||||
if (member && !canActOn(pluginData, author, member)) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Cannot massmute one or more users: insufficient permissions"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, "Cannot massmute one or more users: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -87,9 +87,9 @@ export async function actualMassMuteCmd(
|
|||
|
||||
if (failedMutes.length) {
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Muted ${successfulMuteCount} users, ${failedMutes.length} failed: ${failedMutes.join(" ")}`,
|
||||
);
|
||||
context,
|
||||
`Muted ${successfulMuteCount} users, ${failedMutes.length} failed: ${failedMutes.join(" ")}`,
|
||||
);
|
||||
} else {
|
||||
pluginData.state.common.sendSuccessMessage(context, `Muted ${successfulMuteCount} users successfully`);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd";
|
||||
|
||||
export const MassUnbanMsgCmd = modActionsMsgCmd({
|
||||
trigger: "massunban",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -30,13 +30,7 @@ export const MassUnbanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import { isContextInteraction, sendContextResponse } from "../../../../pluginUti
|
|||
import { MINUTES, noop } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualMassUnbanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -75,10 +75,7 @@ export async function actualMassUnbanCmd(
|
|||
const successfulUnbanCount = userIds.length - failedUnbans.length;
|
||||
if (successfulUnbanCount === 0) {
|
||||
// All unbans failed - don't create a log entry and notify the user
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"All unbans failed. Make sure the IDs are valid and banned."
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, "All unbans failed. Make sure the IDs are valid and banned.");
|
||||
} else {
|
||||
// Some or all unbans were successful. Create a log entry for the mass unban and notify the user.
|
||||
pluginData.getPlugin(LogsPlugin).logMassUnban({
|
||||
|
@ -106,9 +103,9 @@ export async function actualMassUnbanCmd(
|
|||
}
|
||||
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Unbanned ${successfulUnbanCount} users, ${failedUnbans.length} failed:\n${failedMsg}`,
|
||||
);
|
||||
context,
|
||||
`Unbanned ${successfulUnbanCount} users, ${failedUnbans.length} failed:\n${failedMsg}`,
|
||||
);
|
||||
} else {
|
||||
pluginData.state.common.sendSuccessMessage(context, `Unbanned ${successfulUnbanCount} users successfully`);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
|||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { actualMuteCmd } from "./actualMuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualMuteCmd } from "./actualMuteCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -49,7 +49,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
if (_isBanned) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
`User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`
|
||||
`User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`,
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -4,11 +4,11 @@ import { canActOn, hasPermission } from "../../../../pluginUtils";
|
|||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { actualMuteCmd } from "./actualMuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualMuteCmd } from "./actualMuteCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "time", description: "The duration of the mute", required: false }),
|
||||
|
@ -54,7 +54,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
if (_isBanned) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
`User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`
|
||||
`User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`,
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
|
@ -66,10 +66,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"User not on server, mute cancelled by moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "User not on server, mute cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -90,10 +87,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,12 @@ import {
|
|||
} from "../../../../utils";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { MuteResult } from "../../../Mutes/types";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import {
|
||||
formatReasonWithAttachments,
|
||||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
/**
|
||||
* The actual function run by both !mute and !forcemute.
|
||||
|
@ -56,10 +59,7 @@ export async function actualMuteCmd(
|
|||
});
|
||||
} catch (e) {
|
||||
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Could not mute the user: no mute role set in config"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, "Could not mute the user: no mute role set in config");
|
||||
} else if (isDiscordAPIError(e) && e.code === 10007) {
|
||||
pluginData.state.common.sendErrorMessage(context, "Could not mute the user: unknown member");
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { actualNoteCmd } from "./actualNoteCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualNoteCmd } from "./actualNoteCmd";
|
||||
|
||||
export const NoteMsgCmd = modActionsMsgCmd({
|
||||
trigger: "note",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualNoteCmd } from "./actualNoteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualNoteCmd } from "./actualNoteCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "note", description: "The note to add to the user", required: false }),
|
||||
|
@ -25,13 +25,7 @@ export const NoteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.note || options.note.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import { CaseTypes } from "../../../../data/CaseTypes";
|
|||
import { UnknownUser, renderUsername } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualNoteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -39,12 +39,12 @@ export async function actualNoteCmd(
|
|||
});
|
||||
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Note added on **${userName}** (Case #${createdCase.case_number})`,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
context,
|
||||
`Note added on **${userName}** (Case #${createdCase.case_number})`,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
|
||||
pluginData.state.events.emit("note", user.id, reason);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { actualUnbanCmd } from "./actualUnbanCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualUnbanCmd } from "./actualUnbanCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -3,9 +3,9 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualUnbanCmd } from "./actualUnbanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualUnbanCmd } from "./actualUnbanCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -29,13 +29,7 @@ export const UnbanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -48,10 +42,7 @@ export const UnbanSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ import { clearExpiringTempban } from "../../../../data/loops/expiringTempbansLoo
|
|||
import { UnknownUser } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualUnbanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -31,10 +31,7 @@ export async function actualUnbanCmd(
|
|||
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
|
||||
await pluginData.guild.bans.remove(user.id as Snowflake, formattedReason ?? undefined);
|
||||
} catch {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Failed to unban member; are you sure they're banned?"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(context, "Failed to unban member; are you sure they're banned?");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualHideCaseCmd } from "../hidecase/actualHideCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualHideCaseCmd } from "../hidecase/actualHideCaseCmd";
|
||||
|
||||
export const UnhideCaseMsgCmd = modActionsMsgCmd({
|
||||
trigger: ["unhide", "unhidecase", "unhide_case"],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualUnhideCaseCmd } from "./actualUnhideCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { actualUnhideCaseCmd } from "./actualUnhideCaseCmd";
|
||||
|
||||
export const UnhideCaseSlashCmd = modActionsSlashCmd({
|
||||
name: "unhidecase",
|
||||
|
|
|
@ -32,6 +32,6 @@ export async function actualUnhideCaseCmd(
|
|||
const amt = caseNumbers.length - failed.length;
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`${amt} case${amt === 1 ? " is" : "s are"} no longer hidden!${failedAddendum}`
|
||||
`${amt} case${amt === 1 ? " is" : "s are"} no longer hidden!${failedAddendum}`,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ import { canActOn, hasPermission } from "../../../../pluginUtils";
|
|||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "./actualUnmuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualUnmuteCmd } from "./actualUnmuteCmd";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -59,7 +59,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
if (banned) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`
|
||||
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`,
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -5,10 +5,10 @@ import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
|||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "./actualUnmuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualUnmuteCmd } from "./actualUnmuteCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "time", description: "The duration of the unmute", required: false }),
|
||||
|
@ -33,13 +33,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -64,7 +58,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
if (banned) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`
|
||||
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`,
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
|
@ -76,10 +70,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"User not on server, unmute cancelled by moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "User not on server, unmute cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -100,10 +91,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ import humanizeDuration from "humanize-duration";
|
|||
import { GuildPluginData } from "knub";
|
||||
import { UnknownUser, asSingleLine, renderUsername } from "../../../../utils";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualUnmuteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { errorMessage, resolveMember, resolveUser } from "../../../../utils";
|
||||
import { actualWarnCmd } from "./actualWarnCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
import { actualWarnCmd } from "./actualWarnCmd";
|
||||
|
||||
export const WarnMsgCmd = modActionsMsgCmd({
|
||||
trigger: "warn",
|
||||
|
|
|
@ -3,11 +3,11 @@ import { slashOptions } from "knub";
|
|||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { actualWarnCmd } from "./actualWarnCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
import { actualWarnCmd } from "./actualWarnCmd";
|
||||
|
||||
const opts = [
|
||||
slashOptions.string({ name: "reason", description: "The reason", required: false }),
|
||||
|
@ -51,7 +51,7 @@ export const WarnSlashCmd = modActionsSlashCmd({
|
|||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
return;
|
||||
|
@ -86,7 +86,7 @@ export const WarnSlashCmd = modActionsSlashCmd({
|
|||
if (!canActAsOther) {
|
||||
await pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
"You don't have permission to act as another moderator",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,13 @@ import { CaseTypes } from "../../../../data/CaseTypes";
|
|||
import { UserNotificationMethod, renderUsername } from "../../../../utils";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import {
|
||||
formatReasonWithAttachments,
|
||||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments";
|
||||
import { warnMember } from "../../functions/warnMember";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualWarnCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -62,7 +65,7 @@ export async function actualWarnCmd(
|
|||
const messageResultText = warnResult.notifyResult.text ? ` (${warnResult.notifyResult.text})` : "";
|
||||
|
||||
await pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Warned **${renderUsername(memberToWarn.user)}** (Case #${warnResult.case.case_number})${messageResultText}`,
|
||||
);
|
||||
context,
|
||||
`Warned **${renderUsername(memberToWarn.user)}** (Case #${warnResult.case.case_number})${messageResultText}`,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { ChatInputCommandInteraction, Message } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import {
|
||||
BasePluginType, pluginUtils,
|
||||
BasePluginType,
|
||||
guildPluginEventListener,
|
||||
guildPluginMessageCommand,
|
||||
guildPluginSlashCommand,
|
||||
guildPluginSlashGroup
|
||||
guildPluginSlashGroup,
|
||||
pluginUtils,
|
||||
} from "knub";
|
||||
import z from "zod";
|
||||
import { Queue } from "../../Queue";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue