[英]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.