因此,每当有人发送图像或消息时,我需要将相同的图像或消息发送到另一个频道,我尝试使用:message.channel.send(message.content)
但这仅适用于消息,您能解释一下如何执行此操作吗?图像一样吗?谢谢
答案 0 :(得分:0)
首先,您希望在邮件中发送附件,然后当然要检查是否有附件!这可以使用 .attachments
类的 message
扩展来完成:
const attachment = message.attachments.first(); // Would get the first attachment found in the message
if (!attachment) return; // Would do nothing if there was no attachment in the message.
完成后,我们可以简单地使用它的 ID 或名称获取一个频道对象,然后通过键入以下内容将附件发送给它:
const channel = message.guild.channels.cache.get('id here'); // Gets the channel object
channel.send('some text here, can be left blank', attachment); // Sends the attachment with text (Will only send the attachment if left blank)