Discord.JS 获取附件 URL 并在频道中发送

Discord.JS Get Attachment URL and send in channel

我有这个机器人代码“discord.js v13”,我需要获取附件的 URL 并立即发送 link。我怎样才能做到这一点?我将代码部分留在下面

            // save file in folder 'musicas'
            stream.pipe(createWriteStream(__dirname + `/musicas/${pegaid}.mp3`)).on('finish', () => {

                // Sending the attachment, and its link
                try {
                    message.channel.send({
                        files: [{
                            attachment: (__dirname + `/musicas/${musicid}.mp3`),
                            name: `${musicid}.mp3`
                        }],
                    });
                } catch (e) {
                    return message.channel.send(`${message.author}, Error ao tentar converter a música!`);
                }

我猜您想发送附件的 URL。很遗憾,您只能先发送附件本身才能发送 URL。

const image = await message.channel.send({ files: [{ attachment: `full-path`, name: `something.mp3` }] });
return message.channel.send({ content: `${image.attachments.first().proxyURL}` });

在 discord.js 文档 here 中阅读更多相关信息 here