[英]Discord Bot Not Playing Audio discord.js v13
我正在尝试制作一个可以在语音频道中播放 mp3 文件的不和谐机器人。但它似乎没有按预期工作
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!');
成功加入语音频道,但根本不播放任何声音
我已通过 console.logging 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 依赖项中的任何一个(如果我错了,请纠正我)
我错过了什么吗?
先感谢您
谢谢,它工作!
我实际上没有在我的问题中显示这一行:
我变了
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
至:
const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES);
const client = new Client({ intents: myIntents });
它现在按预期播放声音
发生在我身上完全一样。 问题在于您在新的 Discord.js 中设置的意图。 更多内容在 reddit 线程链接中。
https://www.reddit.com/r/Discordjs/comments/pprpit/voice_connection_stuck_in_the_signalling_state/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.