'How I can make the bot can play music in stage channel
This is client messageCreate in my code:
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);
}
});
When I send "." in discord, the bot just join the stage channel but it doesn't play music in there. I spend all day to fix this error but it doesn't work
Version package:
Nodejs: v16.13.0
Discord.js: v13.6.0
Npm: v8.3.2
Solution 1:[1]
At the end you have to call:
connection.subscribe(player);
Documentation: https://discord.js.org/#/docs/voice/stable/class/VoiceConnection?scrollTo=subscribe
Guide (with great explanation): https://discordjs.guide/voice/voice-connections.html#playing-audio
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | playlogo |
