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:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue