mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +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
|
@ -0,0 +1,36 @@
|
|||
import { Attachment, ChatInputCommandInteraction, Message, TextBasedChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { isContextMessage } from "../../../pluginUtils";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
|
||||
export async function formatReasonWithMessageLinkForAttachments(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
reason: string,
|
||||
context: Message | ChatInputCommandInteraction,
|
||||
attachments: Attachment[],
|
||||
) {
|
||||
if (isContextMessage(context)) {
|
||||
return context.attachments.size > 0 ? ((reason || "") + " " + context.url).trim() : reason;
|
||||
}
|
||||
|
||||
if (attachments.length < 1) {
|
||||
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 message = await channel!.send({
|
||||
content: `Storing ${attachments.length} attachment${attachments.length === 1 ? "" : "s"}`,
|
||||
files: attachments.map((a) => a.url),
|
||||
});
|
||||
|
||||
return ((reason || "") + " " + message.url).trim();
|
||||
}
|
||||
|
||||
export function formatReasonWithAttachments(reason: string, attachments: Attachment[]) {
|
||||
const attachmentUrls = attachments.map((a) => a.url);
|
||||
return ((reason || "") + " " + attachmentUrls.join(" ")).trim();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue