mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 13:55:03 +00:00
Added Discord attachment link reaction, fixed emoji configuration and moved util functions
This commit is contained in:
parent
a4c4b17a14
commit
592d037148
173 changed files with 1540 additions and 1170 deletions
|
@ -1,17 +1,18 @@
|
|||
import { Attachment, ChatInputCommandInteraction, GuildMember, TextBasedChannel } from "discord.js";
|
||||
import { Attachment, ChatInputCommandInteraction, GuildMember, Message } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../../data/CaseTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../../pluginUtils";
|
||||
import { UserNotificationMethod, renderUserUsername } from "../../../../utils";
|
||||
import { waitForButtonConfirm } from "../../../../utils/waitForInteraction";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { ModActionsPluginType } from "../../types";
|
||||
import { formatReasonWithAttachments } from "../formatReasonWithAttachments";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
|
||||
import { formatReasonWithAttachments, formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
|
||||
import { warnMember } from "../warnMember";
|
||||
|
||||
export async function actualWarnCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
context: TextBasedChannel | ChatInputCommandInteraction,
|
||||
context: Message | ChatInputCommandInteraction,
|
||||
authorId: string,
|
||||
mod: GuildMember,
|
||||
memberToWarn: GuildMember,
|
||||
|
@ -19,8 +20,13 @@ export async function actualWarnCmd(
|
|||
attachments: Attachment[],
|
||||
contactMethods?: UserNotificationMethod[],
|
||||
) {
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, reason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const config = pluginData.config.get();
|
||||
const formattedReason = formatReasonWithAttachments(reason, attachments);
|
||||
const formattedReason = await formatReasonWithMessageLinkForAttachments(pluginData, reason, context, attachments);
|
||||
const formattedReasonWithAttachments = formatReasonWithAttachments(reason, attachments);
|
||||
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const priorWarnAmount = await casesPlugin.getCaseTypeAmountForUserId(memberToWarn.id, CaseTypes.Warn);
|
||||
|
@ -31,12 +37,12 @@ export async function actualWarnCmd(
|
|||
{ confirmText: "Yes", cancelText: "No", restrictToId: authorId },
|
||||
);
|
||||
if (!reply) {
|
||||
sendErrorMessage(pluginData, context, "Warn cancelled by moderator");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Warn cancelled by moderator");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const warnResult = await warnMember(pluginData, memberToWarn, formattedReason, {
|
||||
const warnResult = await warnMember(pluginData, memberToWarn, formattedReason, formattedReasonWithAttachments, {
|
||||
contactMethods,
|
||||
caseArgs: {
|
||||
modId: mod.id,
|
||||
|
@ -47,15 +53,16 @@ export async function actualWarnCmd(
|
|||
});
|
||||
|
||||
if (warnResult.status === "failed") {
|
||||
sendErrorMessage(pluginData, context, "Failed to warn user");
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Failed to warn user");
|
||||
return;
|
||||
}
|
||||
|
||||
const messageResultText = warnResult.notifyResult.text ? ` (${warnResult.notifyResult.text})` : "";
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
context,
|
||||
`Warned **${renderUserUsername(memberToWarn.user)}** (Case #${warnResult.case.case_number})${messageResultText}`,
|
||||
);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
context,
|
||||
`Warned **${renderUserUsername(memberToWarn.user)}** (Case #${warnResult.case.case_number})${messageResultText}`,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue