Chr*_*ero 6 javascript ffmpeg bots discord discord.js
我正在尝试制作一个可以在语音通道中播放 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!');
Run Code Online (Sandbox Code Playgroud)
成功加入语音频道,但根本不播放任何声音
我已通过 console.logging join(__dirname, 'resources/try.mp3') 确保目录名称正确
我还尝试检查在 Discord.js v13 中播放音频所需的依赖项
const { generateDependencyReport } = require('@discordjs/voice');
console.log(generateDependencyReport());
Run Code Online (Sandbox Code Playgroud)
这是输出:
--------------------------------------------------
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
--------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我认为 Discord.js v13 文档说它只需要 Core 、 Opus 、 Encryption 和 FFmpeg 依赖项中的任何一个(如果我错了,请纠正我)
我错过了什么吗?
先感谢您
谢谢,它成功了!
实际上我没有在我的问题中显示这一行:
我变了
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
Run Code Online (Sandbox Code Playgroud)
到:
const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES);
const client = new Client({ intents: myIntents });
Run Code Online (Sandbox Code Playgroud)
现在它按预期播放声音
小智 3
我的情况也完全一样。问题在于您在新的 Discord.js 中设置的意图。更多信息请参见 reddit 主题链接。
https://www.reddit.com/r/Discordjs/comments/pprpit/voice_connection_stuck_in_the_signalling_state/
| 归档时间: |
|
| 查看次数: |
7085 次 |
| 最近记录: |