【发布时间】:2021-11-05 09:52:42
【问题描述】:
在我的机器人播放 mp3 文件时需要一些帮助。我的机器人成功加入语音聊天,播放时长与文件长度相同,但没有播放音频。机器人图标确实亮绿色,但没有声音。
这是代码
await entersState(voiceConn, VoiceConnectionStatus.Ready, 10e3)
const player = createAudioPlayer()
player.on('debug', m => {
console.log(m)
})
player.on('error', error => {
console.error(`Error: ${error}`)
})
const resource = createAudioResource(join(__dirname, '../../songs/song.mp3'))
player.play(resource)
player.on(AudioPlayerStatus.Playing, () => {
console.log('Now playing')
})
voiceConn.subscribe(player)
await interaction.followUp('Playing!')
await entersState(player, AudioPlayerStatus.Idle, 10e3)
voiceConn.destroy()
这是玩家的日志
from {"status":"idle","resource":false,"stepTimeout":false}
to {"status":"buffering","resource":true,"stepTimeout":false}
Now playing
state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
state change:
from {"status":"playing","missedFrames":0,"playbackDuration":8700,"resource":true,"stepTimeout":false}
to {"status":"idle","resource":false,"stepTimeout":false}
【问题讨论】:
标签: typescript discord.js