【发布时间】:2020-02-05 01:48:41
【问题描述】:
我的机器人播放 mp3 声音,但在接近尾声时会中断,尤其是短 (
多次重装ffmpeg
client.on('message', message => {
// Voice only works in guilds, if the message does not come from a guild,
// we ignore it
if (!message.guild) return;
if (message.content === '!sound') {
// Only try to join the sender's voice channel if they are in one themselves
if (message.member.voiceChannel) {
message.member.voiceChannel.join()
.then(connection => { // Connection is an instance of VoiceConnection
const dispatcher = connection.playFile('C:/Users/X/Desktop/my-bot/Sounds/SJW2.mp3');
dispatcher.on("end", end => {connection.disconnect});
})
.catch(console.log);
client.on('end', () => {
// The song has finished
});
没有错误,声音在文件末尾附近被删掉了。
【问题讨论】:
标签: node.js discord discord.js voice