3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-17 15:15:02 +00:00

Finish preliminary rework, ready to test

This commit is contained in:
Dark 2021-06-02 04:07:50 +02:00
parent 57893e7f76
commit d0a1beb809
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
177 changed files with 854 additions and 707 deletions

View file

@ -4,14 +4,15 @@ import { PostPluginType } from "../types";
import { downloadFile } from "../../../utils";
import fs from "fs";
import { formatContent } from "./formatContent";
import { TextChannel, Message, MessageOptions, MessageAttachment } from "discord.js";
const fsp = fs.promises;
export async function postMessage(
pluginData: GuildPluginData<PostPluginType>,
channel: TextChannel,
content: MessageContent,
attachments: Attachment[] = [],
content: MessageOptions,
attachments: MessageAttachment[] = [],
enableMentions: boolean = false,
): Promise<Message> {
if (typeof content === "string") {
@ -27,20 +28,18 @@ export async function postMessage(
if (attachments.length) {
downloadedAttachment = await downloadFile(attachments[0].url);
file = {
name: attachments[0].filename,
name: attachments[0].name,
file: await fsp.readFile(downloadedAttachment.path),
};
}
if (enableMentions) {
content.allowedMentions = {
everyone: true,
users: true,
roles: true,
parse: ["everyone", "roles", "users"],
};
}
const createdMsg = await channel.createMessage(content, file);
const createdMsg = await channel.send(content, file);
pluginData.state.savedMessages.setPermanent(createdMsg.id);
if (downloadedAttachment) {