这会将空文件发送给消息作者。
我该如何解决?我可以在PC上正常播放它们,但是当机器人发送它们时,它不起作用。
if (command == "mp3") {
const filename = message.author.username
const url = args.join(" ");
let stream = ytdl(url, {
encoderArgs: ["-af", "asetrate=44100*1.25,bass=g=20,dynaudnorm=f=150"],
fmt: "mp3",
opusEncoded: false
//downloaded the file
});
stream.pipe(createWriteStream(__dirname + `/downloads/${filename}.mp3`));
//saves it
message.reply(":white_check_mark: check your DM's");
message.author.send({
files: [`./downloads/${filename}.mp3`]
//sends the file to the user
});
}