mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-08 00:05:01 +00:00
Fixes, refactoring and PR feedback
This commit is contained in:
parent
0be54912c4
commit
893a77d562
202 changed files with 1037 additions and 1069 deletions
|
@ -72,6 +72,7 @@ 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: {
|
||||
|
@ -94,7 +95,6 @@ const defaultOptions = {
|
|||
"The user already has **{priorWarnings}** warnings!\n Please check their prior cases and assess whether or not to warn anyways.\n Proceed with the warning?",
|
||||
ban_delete_message_days: 1,
|
||||
attachment_link_reaction: "warn" as AttachmentLinkReactionType,
|
||||
attachment_storing_channel: null,
|
||||
|
||||
can_note: false,
|
||||
can_warn: false,
|
||||
|
@ -236,6 +236,10 @@ export const ModActionsPlugin = guildPlugin<ModActionsPluginType>()({
|
|||
state.events = new EventEmitter();
|
||||
},
|
||||
|
||||
beforeStart(pluginData) {
|
||||
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
|
||||
},
|
||||
|
||||
afterLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
|||
import { CaseTypes } from "../../../../data/CaseTypes";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualAddCaseCmd } from "../../functions/actualCommands/actualAddCaseCmd";
|
||||
import { actualAddCaseCmd } from "./actualAddCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
const opts = {
|
||||
|
@ -28,7 +27,7 @@ export const AddCaseMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -36,7 +35,7 @@ export const AddCaseMsgCmd = modActionsMsgCmd({
|
|||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,7 +45,7 @@ export const AddCaseMsgCmd = modActionsMsgCmd({
|
|||
// Verify the case type is valid
|
||||
const type: string = args.type[0].toUpperCase() + args.type.slice(1).toLowerCase();
|
||||
if (!CaseTypes[type]) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot add case: invalid case type");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot add case: invalid case type");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ import { CaseTypes } from "../../../../data/CaseTypes";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualAddCaseCmd } from "../../functions/actualCommands/actualAddCaseCmd";
|
||||
import { actualAddCaseCmd } from "./actualAddCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -49,9 +48,10 @@ export const AddCaseSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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,11 +5,10 @@ import { Case } from "../../../../data/entities/Case";
|
|||
import { canActOn } from "../../../../pluginUtils";
|
||||
import { UnknownUser, renderUsername, resolveMember } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
|
||||
export async function actualAddCaseCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -28,9 +27,10 @@ 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
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(context, "Cannot add case on this user: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Cannot add case on this user: insufficient permissions"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,11 +47,12 @@ export async function actualAddCaseCmd(
|
|||
});
|
||||
|
||||
if (user) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(context, `Case #${theCase.case_number} created for **${renderUsername(user)}**`);
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Case #${theCase.case_number} created for **${renderUsername(user)}**`
|
||||
);
|
||||
} else {
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(context, `Case #${theCase.case_number} created`);
|
||||
pluginData.state.common.sendSuccessMessage(context, `Case #${theCase.case_number} created`);
|
||||
}
|
||||
|
||||
// Log the action
|
|
@ -1,8 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualBanCmd } from "../../functions/actualCommands/actualBanCmd";
|
||||
import { actualBanCmd } from "./actualBanCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
|
@ -38,7 +37,7 @@ export const BanMsgCmd = modActionsMsgCmd({
|
|||
const user = await resolveUser(pluginData.client, args.user);
|
||||
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,7 +45,7 @@ export const BanMsgCmd = modActionsMsgCmd({
|
|||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,7 +56,7 @@ export const BanMsgCmd = modActionsMsgCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(args) ?? undefined;
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualBanCmd } from "../../functions/actualCommands/actualBanCmd";
|
||||
import { actualBanCmd } from "./actualBanCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
@ -52,9 +51,13 @@ export const BanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -67,9 +70,10 @@ export const BanSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -80,13 +84,13 @@ export const BanSlashCmd = modActionsSlashCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(options) ?? undefined;
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, e.message);
|
||||
pluginData.state.common.sendErrorMessage(interaction, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
|
||||
if (options.time && !convertedTime) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,12 @@ import { UnknownUser, UserNotificationMethod, renderUsername, resolveMember } fr
|
|||
import { banLock } from "../../../../utils/lockNameHelpers";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { banUserId } from "../banUserId";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { isBanned } from "../isBanned";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { banUserId } from "../../functions/banUserId";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
|
||||
export async function actualBanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -54,7 +53,7 @@ export async function actualBanCmd(
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "User not on server, ban cancelled by moderator");
|
||||
pluginData.state.common.sendErrorMessage(context, "User not on server, ban cancelled by moderator");
|
||||
lock.unlock();
|
||||
return;
|
||||
} else {
|
||||
|
@ -63,7 +62,7 @@ export async function actualBanCmd(
|
|||
} else {
|
||||
// Abort if trying to ban user indefinitely if they are already banned indefinitely
|
||||
if (!existingTempban && !time) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `User is already banned indefinitely.`);
|
||||
pluginData.state.common.sendErrorMessage(context, `User is already banned indefinitely.`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -75,9 +74,10 @@ export async function actualBanCmd(
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(context, "User already banned, update cancelled by moderator");
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"User already banned, update cancelled by moderator"
|
||||
);
|
||||
lock.unlock();
|
||||
return;
|
||||
}
|
||||
|
@ -122,9 +122,7 @@ export async function actualBanCmd(
|
|||
});
|
||||
}
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Ban updated to ${time ? "expire in " + humanizeDuration(time) + " from now" : "indefinite"}`,
|
||||
);
|
||||
|
@ -137,11 +135,9 @@ export async function actualBanCmd(
|
|||
if (!forceban && !canActOn(pluginData, author, memberToBan!)) {
|
||||
const ourLevel = getMemberLevel(pluginData, author);
|
||||
const targetLevel = getMemberLevel(pluginData, memberToBan!);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(
|
||||
context,
|
||||
`Cannot ban: target permission level is equal or higher to yours, ${targetLevel} >= ${ourLevel}`,
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
`Cannot ban: target permission level is equal or higher to yours, ${targetLevel} >= ${ourLevel}`,
|
||||
);
|
||||
lock.unlock();
|
||||
return;
|
||||
|
@ -170,7 +166,7 @@ export async function actualBanCmd(
|
|||
);
|
||||
|
||||
if (banResult.status === "failed") {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `Failed to ban member: ${banResult.error}`);
|
||||
pluginData.state.common.sendErrorMessage(context, `Failed to ban member: ${banResult.error}`);
|
||||
lock.unlock();
|
||||
return;
|
||||
}
|
||||
|
@ -190,5 +186,5 @@ export async function actualBanCmd(
|
|||
}
|
||||
|
||||
lock.unlock();
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(context, response);
|
||||
pluginData.state.common.sendSuccessMessage(context, response);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualCaseCmd } from "../../functions/actualCommands/actualCaseCmd";
|
||||
import { actualCaseCmd } from "./actualCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
const opts = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualCaseCmd } from "../../functions/actualCommands/actualCaseCmd";
|
||||
import { actualCaseCmd } from "./actualCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
const opts = [
|
||||
|
|
|
@ -2,7 +2,6 @@ import { ChatInputCommandInteraction, Message } from "discord.js";
|
|||
import { GuildPluginData } from "knub";
|
||||
import { sendContextResponse } from "../../../../pluginUtils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualCaseCmd(
|
||||
|
@ -15,12 +14,12 @@ export async function actualCaseCmd(
|
|||
const theCase = await pluginData.state.cases.findByCaseNumber(caseNumber);
|
||||
|
||||
if (!theCase) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Case not found", undefined, undefined, show !== true);
|
||||
void pluginData.state.common.sendErrorMessage(context, "Case not found", undefined, undefined, show !== true);
|
||||
return;
|
||||
}
|
||||
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const embed = await casesPlugin.getCaseEmbed(theCase.id, authorId);
|
||||
|
||||
sendContextResponse(context, { ...embed, ephemeral: show !== true });
|
||||
void sendContextResponse(context, { ...embed, ephemeral: show !== true });
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualCasesCmd } from "../../functions/actualCommands/actualCasesCmd";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
const opts = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { actualCasesCmd } from "../../functions/actualCommands/actualCasesCmd";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
const opts = [
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { resolveMember, resolveUser, UnknownUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualCasesCmd } from "../../functions/actualCommands/actualCasesCmd";
|
||||
import { actualCasesCmd } from "./actualCasesCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
const opts = {
|
||||
|
@ -38,7 +37,7 @@ export const CasesUserMsgCmd = modActionsMsgCmd({
|
|||
(await resolveUser(pluginData.client, args.user));
|
||||
|
||||
if (user instanceof UnknownUser) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import { asyncMap } from "../../../../utils/async";
|
|||
import { createPaginatedMessage } from "../../../../utils/createPaginatedMessage";
|
||||
import { getGuildPrefix } from "../../../../utils/getGuildPrefix";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
const casesPerPage = 5;
|
||||
|
@ -160,9 +159,13 @@ async function casesModCmd(
|
|||
const totalCases = await casesPlugin.getTotalCasesByMod(modId ?? author.id, casesFilters);
|
||||
|
||||
if (totalCases === 0) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(context, `No cases by **${modName}**`, undefined, undefined, !show);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
`No cases by **${modName}**`,
|
||||
undefined,
|
||||
undefined,
|
||||
!show
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { trimLines } from "../../../../utils";
|
||||
import { actualDeleteCaseCmd } from "../../functions/actualCommands/actualDeleteCaseCmd";
|
||||
import { actualDeleteCaseCmd } from "./actualDeleteCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
export const DeleteCaseMsgCmd = modActionsMsgCmd({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { actualDeleteCaseCmd } from "../../functions/actualCommands/actualDeleteCaseCmd";
|
||||
import { actualDeleteCaseCmd } from "./actualDeleteCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
const opts = [slashOptions.boolean({ name: "force", description: "Whether or not to force delete", required: false })];
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Case } from "../../../../data/entities/Case";
|
|||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { SECONDS, renderUsername } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { TimeAndDatePlugin } from "../../../TimeAndDate/TimeAndDatePlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
@ -31,7 +30,7 @@ export async function actualDeleteCaseCmd(
|
|||
}
|
||||
|
||||
if (failed.length === caseNumbers.length) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "None of the cases were found!");
|
||||
pluginData.state.common.sendErrorMessage(context, "None of the cases were found!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,13 +82,15 @@ export async function actualDeleteCaseCmd(
|
|||
: "";
|
||||
const amt = validCases.length - cancelled;
|
||||
if (amt === 0) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(context, `${amt} case${amt === 1 ? " was" : "s were"} deleted!${failedAddendum}`);
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`${amt} case${amt === 1 ? " was" : "s were"} deleted!${failedAddendum}`
|
||||
);
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualForceBanCmd } from "../../functions/actualCommands/actualForceBanCmd";
|
||||
import { actualForceBanCmd } from "./actualForceBanCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
|
@ -27,21 +26,21 @@ export const ForceBanMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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, msg.member, member)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot forceban this user: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot forceban this user: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the user isn't already banned
|
||||
const banned = await isBanned(pluginData, user.id);
|
||||
if (banned) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User is already banned`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User is already banned`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,7 @@ export const ForceBanMsgCmd = modActionsMsgCmd({
|
|||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualForceBanCmd } from "../../functions/actualCommands/actualForceBanCmd";
|
||||
import { actualForceBanCmd } from "./actualForceBanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -30,9 +29,13 @@ export const ForceBanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -45,9 +48,10 @@ export const ForceBanSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -56,7 +60,7 @@ export const ForceBanSlashCmd = modActionsSlashCmd({
|
|||
|
||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) : null;
|
||||
if (options.time && !convertedTime) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,11 @@ import { CaseTypes } from "../../../../data/CaseTypes";
|
|||
import { LogType } from "../../../../data/LogType";
|
||||
import { DAYS, MINUTES, UnknownUser } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../ignoreEvent";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
|
||||
export async function actualForceBanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -37,7 +36,7 @@ export async function actualForceBanCmd(
|
|||
reason: formattedReasonWithAttachments ?? undefined,
|
||||
});
|
||||
} catch {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Failed to forceban member");
|
||||
pluginData.state.common.sendErrorMessage(context, "Failed to forceban member");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,9 +51,7 @@ export async function actualForceBanCmd(
|
|||
});
|
||||
|
||||
// Confirm the action
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(context, `Member forcebanned (Case #${createdCase.case_number})`);
|
||||
pluginData.state.common.sendSuccessMessage(context, `Member forcebanned (Case #${createdCase.case_number})`);
|
||||
|
||||
// Log the action
|
||||
pluginData.getPlugin(LogsPlugin).logMemberForceban({
|
|
@ -1,8 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
|
||||
import { actualMuteCmd } from "../mute/actualMuteCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
|
@ -36,7 +35,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,7 +43,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
// Make sure we're allowed to mute this user
|
||||
if (memberToMute && !canActOn(pluginData, msg.member, memberToMute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot mute: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot mute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,7 +53,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +65,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(args);
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
|
||||
import { actualMuteCmd } from "../mute/actualMuteCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
@ -47,9 +46,13 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -63,9 +66,10 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -75,7 +79,7 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||
if (options.time && !convertedTime) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +87,7 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(options) ?? undefined;
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, e.message);
|
||||
pluginData.state.common.sendErrorMessage(interaction, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualUnmuteCmd } from "../../functions/actualCommands/actualUnmuteCmd";
|
||||
import { actualUnmuteCmd } from "../unmute/actualUnmuteCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
const opts = {
|
||||
|
@ -33,13 +32,13 @@ export const ForceUnmuteMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if they're muted in the first place
|
||||
if (!(await pluginData.state.mutes.isMuted(user.id))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot unmute: member is not muted");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot unmute: member is not muted");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -48,7 +47,7 @@ export const ForceUnmuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
// Make sure we're allowed to unmute this member
|
||||
if (memberToUnmute && !canActOn(pluginData, msg.member, memberToUnmute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot unmute: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot unmute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -58,7 +57,7 @@ export const ForceUnmuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualUnmuteCmd } from "../../functions/actualCommands/actualUnmuteCmd";
|
||||
import { actualUnmuteCmd } from "../unmute/actualUnmuteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -31,9 +30,13 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -47,9 +50,10 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -59,7 +63,7 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||
if (options.time && !convertedTime) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualHideCaseCmd } from "../../functions/actualCommands/actualHideCaseCmd";
|
||||
import { actualHideCaseCmd } from "./actualHideCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
export const HideCaseMsgCmd = modActionsMsgCmd({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualHideCaseCmd } from "../../functions/actualCommands/actualHideCaseCmd";
|
||||
import { actualHideCaseCmd } from "./actualHideCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
export const HideCaseSlashCmd = modActionsSlashCmd({
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { ChatInputCommandInteraction, Message } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualHideCaseCmd(
|
||||
|
@ -21,7 +20,7 @@ export async function actualHideCaseCmd(
|
|||
}
|
||||
|
||||
if (failed.length === caseNumbers.length) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "None of the cases were found!");
|
||||
pluginData.state.common.sendErrorMessage(context, "None of the cases were found!");
|
||||
return;
|
||||
}
|
||||
const failedAddendum =
|
||||
|
@ -30,9 +29,7 @@ export async function actualHideCaseCmd(
|
|||
: "";
|
||||
|
||||
const amt = caseNumbers.length - failed.length;
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`${amt} case${amt === 1 ? " is" : "s are"} now hidden! Use \`unhidecase\` to unhide them.${failedAddendum}`,
|
||||
);
|
|
@ -1,8 +1,7 @@
|
|||
import { hasPermission } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualKickCmd } from "../../functions/actualCommands/actualKickCmd";
|
||||
import { actualKickCmd } from "./actualKickCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
|
@ -30,7 +29,7 @@ export const KickMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,7 +37,7 @@ export const KickMsgCmd = modActionsMsgCmd({
|
|||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(await pluginData.config.getForMessage(msg), "can_act_as_other"))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,7 @@ export const KickMsgCmd = modActionsMsgCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(args);
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualKickCmd } from "../../functions/actualCommands/actualKickCmd";
|
||||
import { actualKickCmd } from "./actualKickCmd";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
@ -51,9 +50,13 @@ export const KickSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -66,9 +69,10 @@ export const KickSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -79,7 +83,7 @@ export const KickSlashCmd = modActionsSlashCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(options) ?? undefined;
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, e.message);
|
||||
pluginData.state.common.sendErrorMessage(interaction, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ import { GuildPluginData } from "knub";
|
|||
import { LogType } from "../../../../data/LogType";
|
||||
import { canActOn } from "../../../../pluginUtils";
|
||||
import { DAYS, SECONDS, UnknownUser, UserNotificationMethod, renderUsername, resolveMember } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../ignoreEvent";
|
||||
import { isBanned } from "../isBanned";
|
||||
import { kickMember } from "../kickMember";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { kickMember } from "../../functions/kickMember";
|
||||
|
||||
export async function actualKickCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -31,9 +30,9 @@ export async function actualKickCmd(
|
|||
if (!memberToKick) {
|
||||
const banned = await isBanned(pluginData, user.id);
|
||||
if (banned) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `User is banned`);
|
||||
pluginData.state.common.sendErrorMessage(context, `User is banned`);
|
||||
} else {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `User not found on the server`);
|
||||
pluginData.state.common.sendErrorMessage(context, `User not found on the server`);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -41,7 +40,7 @@ export async function actualKickCmd(
|
|||
|
||||
// Make sure we're allowed to kick this member
|
||||
if (!canActOn(pluginData, author, memberToKick)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Cannot kick: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(context, "Cannot kick: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -63,7 +62,7 @@ export async function actualKickCmd(
|
|||
try {
|
||||
await memberToKick.ban({ deleteMessageSeconds: (1 * DAYS) / SECONDS, reason: "kick -clean" });
|
||||
} catch {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Failed to ban the user to clean messages (-clean)");
|
||||
pluginData.state.common.sendErrorMessage(context, "Failed to ban the user to clean messages (-clean)");
|
||||
}
|
||||
|
||||
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_UNBAN, memberToKick.id);
|
||||
|
@ -72,14 +71,14 @@ export async function actualKickCmd(
|
|||
try {
|
||||
await pluginData.guild.bans.remove(memberToKick.id, "kick -clean");
|
||||
} catch {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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)");
|
||||
}
|
||||
}
|
||||
|
||||
if (kickResult.status === "failed") {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `Failed to kick user`);
|
||||
pluginData.state.common.sendErrorMessage(context, `Failed to kick user`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,5 +86,5 @@ export async function actualKickCmd(
|
|||
let response = `Kicked **${renderUsername(memberToKick.user)}** (Case #${kickResult.case.case_number})`;
|
||||
|
||||
if (kickResult.notifyResult.text) response += ` (${kickResult.notifyResult.text})`;
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(context, response);
|
||||
pluginData.state.common.sendSuccessMessage(context, response);
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassBanCmd } from "../../functions/actualCommands/actualMassBanCmd";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
export const MassBanMsgCmd = modActionsMsgCmd({
|
||||
|
@ -22,7 +21,7 @@ export const MassBanMsgCmd = modActionsMsgCmd({
|
|||
const banReasonReply = await waitForReply(pluginData.client, await getContextChannel(msg), msg.author.id);
|
||||
|
||||
if (!banReasonReply || !banReasonReply.content || banReasonReply.content.toLowerCase().trim() === "cancel") {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cancelled");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassBanCmd } from "../../functions/actualCommands/actualMassBanCmd";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -31,9 +30,13 @@ export const MassBanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@ import { humanizeDurationShort } from "../../../../humanizeDurationShort";
|
|||
import { canActOn, getContextChannel, isContextInteraction, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { DAYS, MINUTES, SECONDS, noop } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../ignoreEvent";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
|
||||
export async function actualMassBanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -23,7 +22,7 @@ export async function actualMassBanCmd(
|
|||
) {
|
||||
// Limit to 100 users at once (arbitrary?)
|
||||
if (userIds.length > 100) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `Can only massban max 100 users at once`);
|
||||
pluginData.state.common.sendErrorMessage(context, `Can only massban max 100 users at once`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,9 +37,9 @@ 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
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(context, "Cannot massban one or more users: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Cannot massban one or more users: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +145,7 @@ export async function actualMassBanCmd(
|
|||
const successfulBanCount = userIds.length - failedBans.length;
|
||||
if (successfulBanCount === 0) {
|
||||
// All bans failed - don't create a log entry and notify the user
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "All bans failed. Make sure the IDs are valid.");
|
||||
pluginData.state.common.sendErrorMessage(context, "All bans failed. Make sure the IDs are valid.");
|
||||
} else {
|
||||
// Some or all bans were successful. Create a log entry for the mass ban and notify the user.
|
||||
pluginData.getPlugin(LogsPlugin).logMassBan({
|
||||
|
@ -156,18 +155,17 @@ export async function actualMassBanCmd(
|
|||
});
|
||||
|
||||
if (failedBans.length) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
context,
|
||||
`Banned ${successfulBanCount} users in ${formattedTimeTaken}, ${
|
||||
failedBans.length
|
||||
} failed: ${failedBans.join(" ")}`,
|
||||
);
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Banned ${successfulBanCount} users in ${formattedTimeTaken}, ${
|
||||
failedBans.length
|
||||
} failed: ${failedBans.join(" ")}`,
|
||||
);
|
||||
} else {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(context, `Banned ${successfulBanCount} users successfully in ${formattedTimeTaken}`);
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Banned ${successfulBanCount} users successfully in ${formattedTimeTaken}`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,8 +1,7 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassMuteCmd } from "../../functions/actualCommands/actualMassMuteCmd";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
export const MassMuteMsgCmd = modActionsMsgCmd({
|
||||
|
@ -25,7 +24,7 @@ export const MassMuteMsgCmd = modActionsMsgCmd({
|
|||
!muteReasonReceived.content ||
|
||||
muteReasonReceived.content.toLowerCase().trim() === "cancel"
|
||||
) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cancelled");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassMuteCmd } from "../../functions/actualCommands/actualMassMuteCmd";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -31,9 +30,13 @@ export const MassMuteSlashSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,12 +3,11 @@ import { GuildPluginData } from "knub";
|
|||
import { LogType } from "../../../../data/LogType";
|
||||
import { logger } from "../../../../logger";
|
||||
import { canActOn, isContextInteraction, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
|
||||
export async function actualMassMuteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -20,7 +19,7 @@ export async function actualMassMuteCmd(
|
|||
) {
|
||||
// Limit to 100 users at once (arbitrary?)
|
||||
if (userIds.length > 100) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `Can only massmute max 100 users at once`);
|
||||
pluginData.state.common.sendErrorMessage(context, `Can only massmute max 100 users at once`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -35,9 +34,10 @@ 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
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(context, "Cannot massmute one or more users: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"Cannot massmute one or more users: insufficient permissions"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ export async function actualMassMuteCmd(
|
|||
const successfulMuteCount = userIds.length - failedMutes.length;
|
||||
if (successfulMuteCount === 0) {
|
||||
// All mutes failed
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "All mutes failed. Make sure the IDs are valid.");
|
||||
pluginData.state.common.sendErrorMessage(context, "All mutes failed. Make sure the IDs are valid.");
|
||||
} else {
|
||||
// Success on all or some mutes
|
||||
pluginData.getPlugin(LogsPlugin).logMassMute({
|
||||
|
@ -86,14 +86,12 @@ export async function actualMassMuteCmd(
|
|||
});
|
||||
|
||||
if (failedMutes.length) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Muted ${successfulMuteCount} users, ${failedMutes.length} failed: ${failedMutes.join(" ")}`,
|
||||
);
|
||||
} else {
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(context, `Muted ${successfulMuteCount} users successfully`);
|
||||
pluginData.state.common.sendSuccessMessage(context, `Muted ${successfulMuteCount} users successfully`);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassUnbanCmd } from "../../functions/actualCommands/actualMassUnbanCmd";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
export const MassUnbanMsgCmd = modActionsMsgCmd({
|
||||
|
@ -21,7 +20,7 @@ export const MassUnbanMsgCmd = modActionsMsgCmd({
|
|||
sendContextResponse(msg, "Unban reason? `cancel` to cancel");
|
||||
const unbanReasonReply = await waitForReply(pluginData.client, await getContextChannel(msg), msg.author.id);
|
||||
if (!unbanReasonReply || !unbanReasonReply.content || unbanReasonReply.content.toLowerCase().trim() === "cancel") {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cancelled");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMassUnbanCmd } from "../../functions/actualCommands/actualMassUnbanCmd";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -31,9 +30,13 @@ export const MassUnbanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,12 @@ import { LogType } from "../../../../data/LogType";
|
|||
import { isContextInteraction, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { MINUTES, noop } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../ignoreEvent";
|
||||
import { isBanned } from "../isBanned";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
|
||||
export async function actualMassUnbanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -23,7 +22,7 @@ export async function actualMassUnbanCmd(
|
|||
) {
|
||||
// Limit to 100 users at once (arbitrary?)
|
||||
if (userIds.length > 100) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `Can only mass-unban max 100 users at once`);
|
||||
pluginData.state.common.sendErrorMessage(context, `Can only mass-unban max 100 users at once`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -76,9 +75,10 @@ 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
|
||||
.getPlugin(CommonPlugin)
|
||||
.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({
|
||||
|
@ -105,16 +105,12 @@ export async function actualMassUnbanCmd(
|
|||
});
|
||||
}
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Unbanned ${successfulUnbanCount} users, ${failedUnbans.length} failed:\n${failedMsg}`,
|
||||
);
|
||||
} else {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(context, `Unbanned ${successfulUnbanCount} users successfully`);
|
||||
pluginData.state.common.sendSuccessMessage(context, `Unbanned ${successfulUnbanCount} users successfully`);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,7 @@ import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
|||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
|
||||
import { actualMuteCmd } from "./actualMuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
@ -38,7 +37,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -48,9 +47,10 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
const _isBanned = await isBanned(pluginData, user.id);
|
||||
const prefix = pluginData.fullConfig.prefix;
|
||||
if (_isBanned) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, `User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
`User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
// Ask the mod if we should upgrade to a forcemute as the user is not on the server
|
||||
|
@ -61,7 +61,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "User not on server, mute cancelled by moderator");
|
||||
pluginData.state.common.sendErrorMessage(msg, "User not on server, mute cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
// Make sure we're allowed to mute this member
|
||||
if (memberToMute && !canActOn(pluginData, msg.member, memberToMute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot mute: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot mute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(args);
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ import { canActOn, hasPermission } from "../../../../pluginUtils";
|
|||
import { UserNotificationMethod, convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualMuteCmd } from "../../functions/actualCommands/actualMuteCmd";
|
||||
import { actualMuteCmd } from "./actualMuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
@ -53,9 +52,10 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
const _isBanned = await isBanned(pluginData, options.user.id);
|
||||
const prefix = pluginData.fullConfig.prefix;
|
||||
if (_isBanned) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, `User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
`User is banned. Use \`${prefix}forcemute\` if you want to mute them anyway.`
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
// Ask the mod if we should upgrade to a forcemute as the user is not on the server
|
||||
|
@ -66,9 +66,10 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "User not on server, mute cancelled by moderator");
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"User not on server, mute cancelled by moderator"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
// Make sure we're allowed to mute this member
|
||||
if (memberToMute && !canActOn(pluginData, interaction.member as GuildMember, memberToMute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, "Cannot mute: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Cannot mute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -89,9 +90,10 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -101,7 +103,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||
if (options.time && !convertedTime) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -109,7 +111,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(options) ?? undefined;
|
||||
} catch (e) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, e.message);
|
||||
pluginData.state.common.sendErrorMessage(interaction, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,11 @@ import {
|
|||
isDiscordAPIError,
|
||||
renderUsername,
|
||||
} from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { MuteResult } from "../../../Mutes/types";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
|
||||
/**
|
||||
* The actual function run by both !mute and !forcemute.
|
||||
|
@ -57,11 +56,12 @@ export async function actualMuteCmd(
|
|||
});
|
||||
} catch (e) {
|
||||
if (e instanceof RecoverablePluginError && e.code === ERRORS.NO_MUTE_ROLE_IN_CONFIG) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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.getPlugin(CommonPlugin).sendErrorMessage(context, "Could not mute the user: unknown member");
|
||||
pluginData.state.common.sendErrorMessage(context, "Could not mute the user: unknown member");
|
||||
} else {
|
||||
logger.error(`Failed to mute user ${user.id}: ${e.stack}`);
|
||||
if (user.id == null) {
|
||||
|
@ -69,7 +69,7 @@ export async function actualMuteCmd(
|
|||
// tslint:disable-next-line:no-console
|
||||
console.trace("[DEBUG] Null user.id for mute");
|
||||
}
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Could not mute the user");
|
||||
pluginData.state.common.sendErrorMessage(context, "Could not mute the user");
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -104,5 +104,5 @@ export async function actualMuteCmd(
|
|||
}
|
||||
|
||||
if (muteResult.notifyResult.text) response += ` (${muteResult.notifyResult.text})`;
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(context, response);
|
||||
pluginData.state.common.sendSuccessMessage(context, response);
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualNoteCmd } from "../../functions/actualCommands/actualNoteCmd";
|
||||
import { actualNoteCmd } from "./actualNoteCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
export const NoteMsgCmd = modActionsMsgCmd({
|
||||
|
@ -17,12 +16,12 @@ export const NoteMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.note && msg.attachments.size === 0) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Text or attachment required");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Text or attachment required");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualNoteCmd } from "../../functions/actualCommands/actualNoteCmd";
|
||||
import { actualNoteCmd } from "./actualNoteCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -26,9 +25,13 @@ export const NoteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.note || options.note.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@ import { GuildPluginData } from "knub";
|
|||
import { CaseTypes } from "../../../../data/CaseTypes";
|
||||
import { UnknownUser, renderUsername } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
|
||||
export async function actualNoteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -39,9 +38,7 @@ export async function actualNoteCmd(
|
|||
reason,
|
||||
});
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Note added on **${userName}** (Case #${createdCase.case_number})`,
|
||||
undefined,
|
|
@ -1,8 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualUnbanCmd } from "../../functions/actualCommands/actualUnbanCmd";
|
||||
import { actualUnbanCmd } from "./actualUnbanCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
const opts = {
|
||||
|
@ -26,7 +25,7 @@ export const UnbanMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,7 +33,7 @@ export const UnbanMsgCmd = modActionsMsgCmd({
|
|||
let mod = msg.member;
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg, channelId: msg.channel.id }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ import { slashOptions } from "knub";
|
|||
import { hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualUnbanCmd } from "../../functions/actualCommands/actualUnbanCmd";
|
||||
import { actualUnbanCmd } from "./actualUnbanCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
||||
|
@ -30,9 +29,13 @@ export const UnbanSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -45,9 +48,10 @@ export const UnbanSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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,12 +5,11 @@ import { LogType } from "../../../../data/LogType";
|
|||
import { clearExpiringTempban } from "../../../../data/loops/expiringTempbansLoop";
|
||||
import { UnknownUser } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { IgnoredEventType, ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../ignoreEvent";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { ignoreEvent } from "../../functions/ignoreEvent";
|
||||
|
||||
export async function actualUnbanCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -32,9 +31,10 @@ export async function actualUnbanCmd(
|
|||
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
|
||||
await pluginData.guild.bans.remove(user.id as Snowflake, formattedReason ?? undefined);
|
||||
} catch {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ export async function actualUnbanCmd(
|
|||
}
|
||||
|
||||
// Confirm the action
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(context, `Member unbanned (Case #${createdCase.case_number})`);
|
||||
pluginData.state.common.sendSuccessMessage(context, `Member unbanned (Case #${createdCase.case_number})`);
|
||||
|
||||
// Log the action
|
||||
pluginData.getPlugin(LogsPlugin).logMemberUnban({
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { actualHideCaseCmd } from "../../functions/actualCommands/actualHideCaseCmd";
|
||||
import { actualHideCaseCmd } from "../hidecase/actualHideCaseCmd";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
export const UnhideCaseMsgCmd = modActionsMsgCmd({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { slashOptions } from "knub";
|
||||
import { actualUnhideCaseCmd } from "../../functions/actualCommands/actualUnhideCaseCmd";
|
||||
import { actualUnhideCaseCmd } from "./actualUnhideCaseCmd";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
||||
export const UnhideCaseSlashCmd = modActionsSlashCmd({
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { ChatInputCommandInteraction, Message } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
|
||||
export async function actualUnhideCaseCmd(
|
||||
|
@ -21,7 +20,7 @@ export async function actualUnhideCaseCmd(
|
|||
}
|
||||
|
||||
if (failed.length === caseNumbers.length) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "None of the cases were found!");
|
||||
pluginData.state.common.sendErrorMessage(context, "None of the cases were found!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -31,7 +30,8 @@ export async function actualUnhideCaseCmd(
|
|||
: "";
|
||||
|
||||
const amt = caseNumbers.length - failed.length;
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(context, `${amt} case${amt === 1 ? " is" : "s are"} no longer hidden!${failedAddendum}`);
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`${amt} case${amt === 1 ? " is" : "s are"} no longer hidden!${failedAddendum}`
|
||||
);
|
||||
}
|
|
@ -2,9 +2,8 @@ import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
|||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { resolveMember, resolveUser } from "../../../../utils";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "../../functions/actualCommands/actualUnmuteCmd";
|
||||
import { actualUnmuteCmd } from "./actualUnmuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
||||
|
@ -36,7 +35,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -50,7 +49,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
!hasMuteRole &&
|
||||
!memberToUnmute?.isCommunicationDisabled()
|
||||
) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot unmute: member is not muted");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot unmute: member is not muted");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -58,9 +57,10 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
const banned = await isBanned(pluginData, user.id);
|
||||
const prefix = pluginData.fullConfig.prefix;
|
||||
if (banned) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(msg, `User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
msg,
|
||||
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
// Ask the mod if we should upgrade to a forceunmute as the user is not on the server
|
||||
|
@ -71,7 +71,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "User not on server, unmute cancelled by moderator");
|
||||
pluginData.state.common.sendErrorMessage(msg, "User not on server, unmute cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
// Make sure we're allowed to unmute this member
|
||||
if (memberToUnmute && !canActOn(pluginData, msg.member, memberToUnmute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot unmute: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(msg, "Cannot unmute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
|
||||
if (args.mod) {
|
||||
if (!(await hasPermission(pluginData, "can_act_as_other", { message: msg }))) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
pluginData.state.common.sendErrorMessage(msg, "You don't have permission to use -mod");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,8 @@ import { canActOn, hasPermission } from "../../../../pluginUtils";
|
|||
import { convertDelayStringToMS, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { actualUnmuteCmd } from "../../functions/actualCommands/actualUnmuteCmd";
|
||||
import { actualUnmuteCmd } from "./actualUnmuteCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
import { NUMBER_ATTACHMENTS_CASE_CREATION } from "../constants";
|
||||
|
@ -34,9 +33,13 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -51,7 +54,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
!hasMuteRole &&
|
||||
!memberToUnmute?.isCommunicationDisabled()
|
||||
) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, "Cannot unmute: member is not muted");
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Cannot unmute: member is not muted");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -59,9 +62,10 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
const banned = await isBanned(pluginData, options.user.id);
|
||||
const prefix = pluginData.fullConfig.prefix;
|
||||
if (banned) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, `User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
`User is banned. Use \`${prefix}forceunmute\` to unmute them anyway.`
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
// Ask the mod if we should upgrade to a forceunmute as the user is not on the server
|
||||
|
@ -72,9 +76,10 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
);
|
||||
|
||||
if (!reply) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "User not on server, unmute cancelled by moderator");
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"User not on server, unmute cancelled by moderator"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +87,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
// Make sure we're allowed to unmute this member
|
||||
if (memberToUnmute && !canActOn(pluginData, interaction.member as GuildMember, memberToUnmute)) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, "Cannot unmute: insufficient permissions");
|
||||
pluginData.state.common.sendErrorMessage(interaction, "Cannot unmute: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -95,9 +100,10 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.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;
|
||||
}
|
||||
|
||||
|
@ -107,7 +113,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
|
||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
||||
if (options.time && !convertedTime) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@ import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } f
|
|||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { UnknownUser, asSingleLine, renderUsername } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
|
||||
export async function actualUnmuteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -35,14 +34,14 @@ export async function actualUnmuteCmd(
|
|||
});
|
||||
|
||||
if (!result) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "User is not muted!");
|
||||
pluginData.state.common.sendErrorMessage(context, "User is not muted!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Confirm the action to the moderator
|
||||
if (time) {
|
||||
const timeUntilUnmute = time && humanizeDuration(time);
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
asSingleLine(`
|
||||
Unmuting **${renderUsername(user)}**
|
||||
|
@ -50,7 +49,7 @@ export async function actualUnmuteCmd(
|
|||
`),
|
||||
);
|
||||
} else {
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(
|
||||
pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
asSingleLine(`
|
||||
Unmuted **${renderUsername(user)}**
|
|
@ -1,8 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../../commandTypes";
|
||||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { errorMessage, resolveMember, resolveUser } from "../../../../utils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualWarnCmd } from "../../functions/actualCommands/actualWarnCmd";
|
||||
import { actualWarnCmd } from "./actualWarnCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsMsgCmd } from "../../types";
|
||||
|
@ -24,7 +23,7 @@ export const WarnMsgCmd = modActionsMsgCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user.id) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found`);
|
||||
await pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -33,9 +32,9 @@ export const WarnMsgCmd = modActionsMsgCmd({
|
|||
if (!memberToWarn) {
|
||||
const _isBanned = await isBanned(pluginData, user.id);
|
||||
if (_isBanned) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User is banned`);
|
||||
await pluginData.state.common.sendErrorMessage(msg, `User is banned`);
|
||||
} else {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, `User not found on the server`);
|
||||
await pluginData.state.common.sendErrorMessage(msg, `User not found on the server`);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -43,7 +42,7 @@ export const WarnMsgCmd = modActionsMsgCmd({
|
|||
|
||||
// Make sure we're allowed to warn this member
|
||||
if (!canActOn(pluginData, msg.member, memberToWarn)) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, "Cannot warn: insufficient permissions");
|
||||
await pluginData.state.common.sendErrorMessage(msg, "Cannot warn: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -62,7 +61,7 @@ export const WarnMsgCmd = modActionsMsgCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(args);
|
||||
} catch (e) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(msg, e.message);
|
||||
await pluginData.state.common.sendErrorMessage(msg, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ import { slashOptions } from "knub";
|
|||
import { canActOn, hasPermission } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, resolveMember } from "../../../../utils";
|
||||
import { generateAttachmentSlashOptions, retrieveMultipleOptions } from "../../../../utils/multipleSlashOptions";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { actualWarnCmd } from "../../functions/actualCommands/actualWarnCmd";
|
||||
import { actualWarnCmd } from "./actualWarnCmd";
|
||||
import { isBanned } from "../../functions/isBanned";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs";
|
||||
import { modActionsSlashCmd } from "../../types";
|
||||
|
@ -47,9 +46,13 @@ export const WarnSlashCmd = modActionsSlashCmd({
|
|||
const attachments = retrieveMultipleOptions(NUMBER_ATTACHMENTS_CASE_CREATION, options, "attachment");
|
||||
|
||||
if ((!options.reason || options.reason.trim() === "") && attachments.length < 1) {
|
||||
await pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "Text or attachment required", undefined, undefined, true);
|
||||
await pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"Text or attachment required",
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -59,9 +62,9 @@ export const WarnSlashCmd = modActionsSlashCmd({
|
|||
if (!memberToWarn) {
|
||||
const _isBanned = await isBanned(pluginData, options.user.id);
|
||||
if (_isBanned) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `User is banned`);
|
||||
await pluginData.state.common.sendErrorMessage(interaction, `User is banned`);
|
||||
} else {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, `User not found on the server`);
|
||||
await pluginData.state.common.sendErrorMessage(interaction, `User not found on the server`);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -69,7 +72,7 @@ export const WarnSlashCmd = modActionsSlashCmd({
|
|||
|
||||
// Make sure we're allowed to warn this member
|
||||
if (!canActOn(pluginData, interaction.member as GuildMember, memberToWarn)) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, "Cannot warn: insufficient permissions");
|
||||
await pluginData.state.common.sendErrorMessage(interaction, "Cannot warn: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,9 +84,10 @@ export const WarnSlashCmd = modActionsSlashCmd({
|
|||
|
||||
if (options.mod) {
|
||||
if (!canActAsOther) {
|
||||
await pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(interaction, "You don't have permission to act as another moderator");
|
||||
await pluginData.state.common.sendErrorMessage(
|
||||
interaction,
|
||||
"You don't have permission to act as another moderator"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -94,7 +98,7 @@ export const WarnSlashCmd = modActionsSlashCmd({
|
|||
try {
|
||||
contactMethods = readContactMethodsFromArgs(options) ?? undefined;
|
||||
} catch (e) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(interaction, e.message);
|
||||
await pluginData.state.common.sendErrorMessage(interaction, e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@ import { CaseTypes } from "../../../../data/CaseTypes";
|
|||
import { UserNotificationMethod, renderUsername } from "../../../../utils";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { warnMember } from "../warnMember";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../../functions/formatReasonForAttachments";
|
||||
import { warnMember } from "../../functions/warnMember";
|
||||
|
||||
export async function actualWarnCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
@ -37,7 +36,7 @@ export async function actualWarnCmd(
|
|||
{ confirmText: "Yes", cancelText: "No", restrictToId: authorId },
|
||||
);
|
||||
if (!reply) {
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Warn cancelled by moderator");
|
||||
await pluginData.state.common.sendErrorMessage(context, "Warn cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -55,16 +54,14 @@ export async function actualWarnCmd(
|
|||
if (warnResult.status === "failed") {
|
||||
const failReason = warnResult.error ? `: ${warnResult.error}` : "";
|
||||
|
||||
await pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, `Failed to warn user${failReason}`);
|
||||
await pluginData.state.common.sendErrorMessage(context, `Failed to warn user${failReason}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const messageResultText = warnResult.notifyResult.text ? ` (${warnResult.notifyResult.text})` : "";
|
||||
|
||||
await pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
await pluginData.state.common.sendSuccessMessage(
|
||||
context,
|
||||
`Warned **${renderUsername(memberToWarn.user)}** (Case #${warnResult.case.case_number})${messageResultText}`,
|
||||
);
|
|
@ -1,6 +1,5 @@
|
|||
import { ChatInputCommandInteraction, Message, TextBasedChannel } from "discord.js";
|
||||
import { AnyPluginData, GuildPluginData } from "knub";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
|
||||
export function shouldReactToAttachmentLink(pluginData: GuildPluginData<ModActionsPluginType>) {
|
||||
|
@ -22,16 +21,14 @@ export function sendAttachmentLinkDetectionErrorMessage(
|
|||
context: TextBasedChannel | Message | ChatInputCommandInteraction,
|
||||
restricted = false,
|
||||
) {
|
||||
const emoji = pluginData.getPlugin(CommonPlugin).getErrorEmoji();
|
||||
const emoji = pluginData.state.common.getErrorEmoji();
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendErrorMessage(
|
||||
context,
|
||||
"You manually added a Discord attachment link to the reason. This link will only work for a limited time.\n" +
|
||||
"You should instead **re-upload** the attachment with the command, in the same message.\n\n" +
|
||||
(restricted ? `${emoji} **Command canceled.** ${emoji}` : "").trim(),
|
||||
);
|
||||
pluginData.state.common.sendErrorMessage(
|
||||
context,
|
||||
"You manually added a Discord attachment link to the reason. This link will only work for a limited time.\n" +
|
||||
"You should instead **re-upload** the attachment with the command, in the same message.\n\n" +
|
||||
(restricted ? `${emoji} **Command canceled.** ${emoji}` : "").trim(),
|
||||
);
|
||||
}
|
||||
|
||||
export async function handleAttachmentLinkDetectionAndGetRestriction(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Attachment, ChatInputCommandInteraction, Message, TextBasedChannel } from "discord.js";
|
||||
import { Attachment, ChatInputCommandInteraction, Message } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { isContextMessage } from "../../../pluginUtils";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
|
@ -19,17 +19,9 @@ export async function formatReasonWithMessageLinkForAttachments(
|
|||
return reason;
|
||||
}
|
||||
|
||||
const attachmentChannelId = pluginData.config.get().attachment_storing_channel;
|
||||
const channel = attachmentChannelId
|
||||
? (pluginData.guild.channels.cache.get(attachmentChannelId) as TextBasedChannel) ?? context.channel
|
||||
: context.channel;
|
||||
const attachmentsMessage = await pluginData.state.common.storeAttachmentsAsMessage(attachments, context.channel);
|
||||
|
||||
const message = await channel!.send({
|
||||
content: `Storing ${attachments.length} attachment${attachments.length === 1 ? "" : "s"}`,
|
||||
files: attachments.map((a) => a.url),
|
||||
});
|
||||
|
||||
return ((reason || "") + " " + message.url).trim();
|
||||
return ((reason || "") + " " + attachmentsMessage.url).trim();
|
||||
}
|
||||
|
||||
export function formatReasonWithAttachments(reason: string, attachments: Attachment[]) {
|
||||
|
|
|
@ -3,7 +3,6 @@ import { GuildPluginData } from "knub";
|
|||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "./attachmentLinkReaction";
|
||||
|
@ -25,12 +24,12 @@ export async function updateCase(
|
|||
}
|
||||
|
||||
if (!theCase) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Case not found");
|
||||
pluginData.state.common.sendErrorMessage(context, "Case not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (note.length === 0 && attachments.length === 0) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Text or attachment required");
|
||||
pluginData.state.common.sendErrorMessage(context, "Text or attachment required");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,5 +53,5 @@ export async function updateCase(
|
|||
note: formattedNote,
|
||||
});
|
||||
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(context, `Case \`#${theCase.case_number}\` updated`);
|
||||
pluginData.state.common.sendSuccessMessage(context, `Case \`#${theCase.case_number}\` updated`);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { ChatInputCommandInteraction, Message } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import {
|
||||
BasePluginType,
|
||||
BasePluginType, pluginUtils,
|
||||
guildPluginEventListener,
|
||||
guildPluginMessageCommand,
|
||||
guildPluginSlashCommand,
|
||||
guildPluginSlashGroup,
|
||||
guildPluginSlashGroup
|
||||
} from "knub";
|
||||
import z from "zod";
|
||||
import { Queue } from "../../Queue";
|
||||
|
@ -16,6 +16,7 @@ import { GuildTempbans } from "../../data/GuildTempbans";
|
|||
import { Case } from "../../data/entities/Case";
|
||||
import { UserNotificationMethod, UserNotificationResult } from "../../utils";
|
||||
import { CaseArgs } from "../Cases/types";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
|
||||
export type AttachmentLinkReactionType = "none" | "warn" | "restrict" | null;
|
||||
|
||||
|
@ -38,7 +39,6 @@ export const zModActionsConfig = z.strictObject({
|
|||
warn_notify_message: z.string(),
|
||||
ban_delete_message_days: z.number(),
|
||||
attachment_link_reaction: z.nullable(z.union([z.literal("none"), z.literal("warn"), z.literal("restrict")])),
|
||||
attachment_storing_channel: z.nullable(z.string()),
|
||||
can_note: z.boolean(),
|
||||
can_warn: z.boolean(),
|
||||
can_mute: z.boolean(),
|
||||
|
@ -84,6 +84,8 @@ export interface ModActionsPluginType extends BasePluginType {
|
|||
massbanQueue: Queue;
|
||||
|
||||
events: ModActionsEventEmitter;
|
||||
|
||||
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue