No sound ( no green circle)

Hello, i followed the official discord js v14 voice guide and my bot is not playing any sound. No green circle too. Here's the code:
const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus, VoiceConnectionStatus, NoSubscriberBehavior } = require('@discordjs/voice');
const fs = require('fs');
const { generateDependencyReport } = require('@discordjs/voice');

module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play audio in your voice channel'),
async execute(interaction) {

const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: false
});

connection.on('stateChange', (oldState, newState) => {
console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`);
});


connection.on(VoiceConnectionStatus.Disconnected, async (oldState, newState) => {
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
entersState(connection, VoiceConnectionStatus.Connecting, 5_000),
]);
// Seems to be reconnecting to a new channel - ignore disconnect
} catch (error) {
// Seems to be a real disconnect which SHOULDN'T be recovered from
connection.destroy();
}
});


const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

player.on('stateChange', (oldState, newState) => {
console.log(`Audio player transitioned from ${oldState.status} to ${newState.status}`);
});

const resource = createAudioResource('../../sound.mp3');

player.play(resource);

const subscription = connection.subscribe(player);

if (subscription) {

setTimeout(() => subscription.unsubscribe(), 5_000);
}

interaction.reply("Now playing")

},
};
const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus, VoiceConnectionStatus, NoSubscriberBehavior } = require('@discordjs/voice');
const fs = require('fs');
const { generateDependencyReport } = require('@discordjs/voice');

module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play audio in your voice channel'),
async execute(interaction) {

const connection = joinVoiceChannel({
channelId: interaction.member.voice.channel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: false
});

connection.on('stateChange', (oldState, newState) => {
console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`);
});


connection.on(VoiceConnectionStatus.Disconnected, async (oldState, newState) => {
try {
await Promise.race([
entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
entersState(connection, VoiceConnectionStatus.Connecting, 5_000),
]);
// Seems to be reconnecting to a new channel - ignore disconnect
} catch (error) {
// Seems to be a real disconnect which SHOULDN'T be recovered from
connection.destroy();
}
});


const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

player.on('stateChange', (oldState, newState) => {
console.log(`Audio player transitioned from ${oldState.status} to ${newState.status}`);
});

const resource = createAudioResource('../../sound.mp3');

player.play(resource);

const subscription = connection.subscribe(player);

if (subscription) {

setTimeout(() => subscription.unsubscribe(), 5_000);
}

interaction.reply("Now playing")

},
};
Here's the generateDependencyReport:
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5
Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found
Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found
FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.17.0
- prism-media: 1.3.5
Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found
Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found
FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
71 Replies
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Xalri
XalriOP5mo ago
[email protected] /home/container └── [email protected] here's what i see in the log:
[9:50:18 PM][🤖・bot] xalri: play /play executed successfully! //i'm logging the interaction
Connection transitioned from signalling to connecting
Connection transitioned from connecting to connecting
Connection transitioned from connecting to connecting
Connection transitioned from connecting to connecting
Connection transitioned from connecting to ready
Audio player transitioned from idle to buffering
Connection transitioned from ready to ready
Audio player transitioned from buffering to playing
Audio player transitioned from playing to idle
[9:50:20 PM][🤖・bot] Bot_Test: Now playing // i'm logging bot's answer
Connection transitioned from ready to ready
[9:50:18 PM][🤖・bot] xalri: play /play executed successfully! //i'm logging the interaction
Connection transitioned from signalling to connecting
Connection transitioned from connecting to connecting
Connection transitioned from connecting to connecting
Connection transitioned from connecting to connecting
Connection transitioned from connecting to ready
Audio player transitioned from idle to buffering
Connection transitioned from ready to ready
Audio player transitioned from buffering to playing
Audio player transitioned from playing to idle
[9:50:20 PM][🤖・bot] Bot_Test: Now playing // i'm logging bot's answer
Connection transitioned from ready to ready
Ethical
Ethical5mo ago
@Xalri i'm facing the same issue
Xalri
XalriOP5mo ago
someone's here:hello: . I didn't work on it after my message since i tried everything i had in mind. If you have any idea, maybe we can help each other. Can you send me your package list from package.json pls?
Ethical
Ethical5mo ago
Yea i fixed it
Xalri
XalriOP5mo ago
omg tell me
Ethical
Ethical5mo ago
Enable the intent GuildVoiceState
Xalri
XalriOP5mo ago
i already added this intents...
Ethical
Ethical5mo ago
GuildVoiceIntents enable?
Xalri
XalriOP5mo ago
in dev portal?
Ethical
Ethical5mo ago
No In your code
Xalri
XalriOP5mo ago
then yes, i already added it oh wait not this one i have guildvoicestate not GuildVoiceIntent
Ethical
Ethical5mo ago
If it's still not work idk then cuz mine is same problem as urs Lol
Xalri
XalriOP5mo ago
GuildVoiceIntent don't exist
Ethical
Ethical5mo ago
Im talking about this
Xalri
XalriOP5mo ago
yes then i have it already
Ethical
Ethical5mo ago
Yea
Xalri
XalriOP5mo ago
i guess i'll have to wait
Ethical
Ethical5mo ago
Idk like I had exactly the same problem as you and it worked as soon as I enabled my intent. Btw what are you trying to do? Music bot?
Xalri
XalriOP5mo ago
it really looks like that, because i followed the guide 3 times and nothing works, all logs says that everything is "ready" or "playing" but i have it. Can you show me how you add intents pls my friend's doing music so i want to add it to my server
Ethical
Ethical5mo ago
Same as mine problem actually i was trying to make Tts command for people who don't like opening the mic on vc So they can use bot.
Xalri
XalriOP5mo ago
good idea
Ethical
Ethical5mo ago
And it's says bot is speaking but it's not so yea as soon i enabled the intent its work Yea wait
Ethical
Ethical5mo ago
No description
Ethical
Ethical5mo ago
@Xalri i mean i know it's not the best idea to enable intents but yes it's fine tho
Xalri
XalriOP5mo ago
wdym? here's mine:
const bot = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildPresences,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildMessageReactions,
],
const bot = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildPresences,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildMessageReactions,
],
Ethical
Ethical5mo ago
I mean we can use other ways To do that Just to make our code clean
Xalri
XalriOP5mo ago
tell me more
Ethical
Ethical5mo ago
import { Client, GatewayIntentBits, Partials, PermissionFlagsBits } from 'discord.js';

const intentsArray = Object.keys(GatewayIntentBits)
.map((a) => GatewayIntentBits[a as keyof typeof GatewayIntentBits]);
const intents = intentsArray.reduce((acc, curr) => acc | curr, 0);

const client = new Client({
intents,
partials: Object.values(Partials) as Partials[],
});
import { Client, GatewayIntentBits, Partials, PermissionFlagsBits } from 'discord.js';

const intentsArray = Object.keys(GatewayIntentBits)
.map((a) => GatewayIntentBits[a as keyof typeof GatewayIntentBits]);
const intents = intentsArray.reduce((acc, curr) => acc | curr, 0);

const client = new Client({
intents,
partials: Object.values(Partials) as Partials[],
});
Like this So we dont have to add intents manually everytime
Xalri
XalriOP5mo ago
what does this do ?
Ethical
Ethical5mo ago
But it's typescript code you can use chatgpt to convert this Into js Enabling the intents
Xalri
XalriOP5mo ago
like all intents?
Ethical
Ethical5mo ago
Yes
Xalri
XalriOP5mo ago
k, let me try
Ethical
Ethical5mo ago
But convert this into js It's ts
Xalri
XalriOP5mo ago
ik
Ethical
Ethical5mo ago
Are you Begginer, intermidiate or advanced ?
Xalri
XalriOP5mo ago
begginer in djs, begginer-intermidiate in js, intermediate in programmation
Ethical
Ethical5mo ago
Nice
Xalri
XalriOP5mo ago
my language is python but dpy is horrible
Ethical
Ethical5mo ago
Can you come to dm
Xalri
XalriOP5mo ago
so i'm trying js
Ethical
Ethical5mo ago
Dpy
Xalri
XalriOP5mo ago
discord.py
Ethical
Ethical5mo ago
Pycord better dpy deperecated
Xalri
XalriOP5mo ago
don't know pycord seems cool
Ethical
Ethical5mo ago
Bruh
Xalri
XalriOP5mo ago
but i'm using djs now, don't make me regret
Ethical
Ethical5mo ago
You dont know pycord
Xalri
XalriOP5mo ago
no
Ethical
Ethical5mo ago
:kek: It's like djs for discord bots Ngl i hate python I'm just saying
Xalri
XalriOP5mo ago
what are partials? like in the code you gave me, you added partial into the client you can dm me
Ethical
Ethical5mo ago
Partials in discord.js refer to a feature that enables Discord bots to receive partial information about certain resources. This includes essential data about entities (like users or channels) without fetching their complete details immediately. By using partials, bots can optimize performance by reducing the number of API calls and processing only necessary information until more details are specifically requested. This feature is particularly useful for managing large volumes of data efficiently and responding promptly to Discord events and interactions.
Xalri
XalriOP5mo ago
cool
d.js docs
d.js docs5mo ago
We highly recommend only specifying the intents you actually need. - Note, that 98303, 32767 or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced. - The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
Narco
Narco4mo ago
Hello, I got the same issue and enable the GuildVoiceState intent but it doesn't work ...
Xalri
XalriOP4mo ago
Adding the intent didn't fix my problem. I'm still searching for a solution
Narco
Narco4mo ago
Okay... I read somewhere that the discordplayer library was down and that the code itself was not at fault Is this false information?
Xalri
XalriOP4mo ago
If you find something to replace it, feel free to share it here
Narco
Narco4mo ago
No problem I will Ok I solve the problem my friend
Xalri
XalriOP4mo ago
Tell me
Narco
Narco4mo ago
It's because of the TOS violation right, you need to apply a filter to your extractors: client.player = new Player(client, { ytdlOptions: { filter: "audioonly", quality: "highestaudio", highWaterMark: 1 << 25 } }); client.player.extractors.loadDefault((ext) => ext !== 'YouTubeExtractor'); But now the new problem is that the music stops after a few seconds ....
Xalri
XalriOP4mo ago
I'm not
Narco
Narco4mo ago
Ah okay okay I didn't know I'm just trying to find a solution What are the other alternatives then? I am a beginner Ah, so in fact it's impossible to make a music bot
Xalri
XalriOP4mo ago
Spotify is not a TOS violation right? Oh
Narco
Narco4mo ago
Hm
Xalri
XalriOP4mo ago
But I'm using my MP4 file so pls continue to help me😭
Narco
Narco4mo ago
So it's impossible to have your own homemade music bot
Xalri
XalriOP4mo ago
It is, but you can't publicly ask for help and talk about it lmao
Narco
Narco4mo ago
:socialmemeblown: Ok well I give up I don't plan to start a band so I can post music
Ethical
Ethical4mo ago
i mean somehow i fixed it but idk how xd oh i think i enabled the voice intent
Want results from more Discord servers?
Add your server