我知道您可以从文件名发送,但我无权访问文件系统,因为我使用的是 Heroku。
client.sendFile(messagedata, writer.toBuffer(), "file.png", "Just a message");
问题是
TypeError: client.sendFile is not a function
discord.js 中的哪个等效函数允许我将缓冲区作为文件发送?
最佳答案
我知道它已经过时了,但这里有一个文本示例,用于在不使用文件系统的情况下在 channel 中发送文件。
const { MessageAttachment } = require('discord.js')
const buffer = Buffer.from('Text in file')
const attachment = new MessageAttachment(buffer, 'file.txt')
channel.send(attachment)
关于javascript - 在 discord.js 中发送文件缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49764610/