我正在尝试制作一个可以在语音频道中播放mp3文件的Discord机器人...但它似乎没有按照预期工作。
connection = joinVoiceChannel({
channelId: voice.channelId,
guildId: interaction.guildId,
adapterCreator: voice.channel.guild.voiceAdapterCreator,
});
let resource = createAudioResource(createReadStream(join(__dirname, 'resources/try.mp3')), {
inlineVolume : true
});
resource.volume.setVolume(0.2);
console.log(join(__dirname, 'resources/try.mp3'));
const player = createAudioPlayer();
connection.subscribe(player);
player.play(resource)
console.log("done");
await interaction.reply('I have joined the voice channel!');
它成功加入了语音频道,但根本没有播放任何声音。
我已经通过控制台记录了 join(__dirname, 'resources/try.mp3') 确认目录名称正确。
我还尝试检查 discord.js v13 播放音频所需的依赖项。
const { generateDependencyReport } = require('@discordjs/voice');
console.log(generateDependencyReport());
以下是输出结果:
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.6.0
- prism-media: 1.3.2
Opus Libraries
- @discordjs/opus: 0.5.3
- opusscript: not found
Encryption Libraries
- sodium: not found
- libsodium-wrappers: 0.7.9
- tweetnacl: not found
FFmpeg
- version: 4.4-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
我认为discord.js v13文档中提到它只需要每个核心(Core),Opus,加密(Encryption)和FFmpeg依赖项中的任何一个(如有错误请指正)。
我是否遗漏了什么?
提前致谢。