0

这是我的代码中的客户端 messageCreate:

    if (msg.author.bot || msg.channel.type == "dm") return;
    if (msg.content.startsWith(".")){
        const player = await createAudioPlayer();
        const connection = await joinVoiceChannel({
            channelId: "935835998397542400",
            guildId: "808674100469432360",
            adapterCreator: msg.guild.voiceAdapterCreator
        });
        await msg.guild.me.voice.setSuppressed(false);
        const stream = await ytdl("https://www.youtube.com/watch?v=21qNxnCS8WU", { 
            filter: 'audioonly',
            quality: 'highestaudio',
            highWaterMark: 1 << 25,
         });
        const resource = await createAudioResource(stream);
        await player.play(resource);
    }
});

当我发送“。” 在不和谐中,机器人只是加入了舞台频道,但它不在那里播放音乐。我花了一整天的时间来修复这个错误,但它不起作用

版本包:

节点: v16.13.0

Discord.js: v13.6.0

Npm : v8.3.2

4

1 回答 1

0

最后,您必须致电:

connection.subscribe(player);

文档: https ://discord.js.org/#/docs/voice/stable/class/VoiceConnection?scrollTo=subscribe

指南(有很好的解释): https ://discordjs.guide/voice/voice-connections.html#playing-audio

于 2022-01-26T16:27:26.190 回答