Discord Bot 不播放音频 discord.js v13
Discord Bot Not Playing Audio discord.js v13
我正在尝试制作一个可以在语音频道中播放 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!');
加入语音频道成功,但完全不播放任何声音
The bot 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 文档说它只需要每个核心、Opus、加密和 FFmpeg 依赖项中的任何一个(如果我错了请纠正我)
我错过了什么吗?
提前致谢
我也遇到过同样的情况。问题在于您在新 Discord.js 中设置的意图。更多内容在 reddit 线程 link.
https://www.reddit.com/r/Discordjs/comments/pprpit/voice_connection_stuck_in_the_signalling_state/
谢谢,成功了!
我实际上并没有在我的问题中显示这一行:
我变了
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 });
它现在按预期播放声音
Bot plays sound
我正在尝试制作一个可以在语音频道中播放 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!');
加入语音频道成功,但完全不播放任何声音
The bot 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 文档说它只需要每个核心、Opus、加密和 FFmpeg 依赖项中的任何一个(如果我错了请纠正我)
我错过了什么吗?
提前致谢
我也遇到过同样的情况。问题在于您在新 Discord.js 中设置的意图。更多内容在 reddit 线程 link.
https://www.reddit.com/r/Discordjs/comments/pprpit/voice_connection_stuck_in_the_signalling_state/
谢谢,成功了!
我实际上并没有在我的问题中显示这一行:
我变了
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 });
它现在按预期播放声音
Bot plays sound