3
0
Fork 0
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:
Lily Bergonzat 2024-02-16 11:51:58 +01:00
parent a4c4b17a14
commit 592d037148
173 changed files with 1540 additions and 1170 deletions

View file

@ -1,7 +1,7 @@
import { GuildMember, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes";
import { isContextInteraction } from "../../../pluginUtils";
import { getContextChannel, isContextInteraction } from "../../../pluginUtils";
import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter";
import { UserNotificationResult, createUserNotificationError, notifyUser, resolveUser, ucfirst } from "../../../utils";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
@ -15,6 +15,7 @@ export async function warnMember(
pluginData: GuildPluginData<ModActionsPluginType>,
member: GuildMember,
reason: string,
reasonWithAttachments: string,
warnOptions: WarnOptions = {},
): Promise<WarnResult> {
const config = pluginData.config.get();
@ -25,7 +26,7 @@ export async function warnMember(
config.warn_message,
new TemplateSafeValueContainer({
guildName: pluginData.guild.name,
reason,
reason: reasonWithAttachments,
moderator: warnOptions.caseArgs?.modId
? userToTemplateSafeUser(await resolveUser(pluginData.client, warnOptions.caseArgs.modId))
: null,
@ -40,8 +41,10 @@ export async function warnMember(
}
if (!notifyResult.success) {
const contextIsChannel = warnOptions.retryPromptContext && !isContextInteraction(warnOptions.retryPromptContext);
const isValidChannel = contextIsChannel && pluginData.guild.channels.resolve(warnOptions.retryPromptContext!.id);
const contextIsNotInteraction =
warnOptions.retryPromptContext && !isContextInteraction(warnOptions.retryPromptContext);
const contextChannel = contextIsNotInteraction ? await getContextChannel(warnOptions.retryPromptContext!) : null;
const isValidChannel = contextIsNotInteraction && pluginData.guild.channels.resolve(contextChannel!.id);
if (!warnOptions.retryPromptContext || !isValidChannel) {
return {