Discord bot wont play audio file(no green circle)

discord.js@14.15.3 node v18.18.1 Im super new to discord js (started yesterday) , or even programming. Ik streaming from yt is not allowed and im want to play from local files that i have in my folder Core Dependencies - @discordjs/voice: 0.17.0 - prism-media: 1.3.5 ----------------------------------------- the report the documentation said to use
Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: 4.1.1
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: not found

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: 4.1.1
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: not found

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
Code
const {
Client,
GatewayIntentBits,
} = require("discord.js");

const {
joinVoiceChannel,
createAudioPlayer,
NoSubscriberBehavior,
createAudioResource
} = require("@discordjs/voice")


const client = new Client(
{
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers
]
}
);

client.on("messageCreate", (message) => {
if (message.author.bot) return
const user = message.author;
const voicechannelId = message.member.voice.channelId;
const guildId = message.guildId;

const connection = joinVoiceChannel({
channelId: voicechannelId,
guildId: guildId,
selfDeaf: true,
adapterCreator: message.guild.voiceAdapterCreator,
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
const resource = createAudioResource('/audio.mp3', { inlineVolume: true })
const subscription = connection.subscribe(player);
player.play(resource);
});

client.login(process.env.BOT_TOKEN);
const {
Client,
GatewayIntentBits,
} = require("discord.js");

const {
joinVoiceChannel,
createAudioPlayer,
NoSubscriberBehavior,
createAudioResource
} = require("@discordjs/voice")


const client = new Client(
{
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMembers
]
}
);

client.on("messageCreate", (message) => {
if (message.author.bot) return
const user = message.author;
const voicechannelId = message.member.voice.channelId;
const guildId = message.guildId;

const connection = joinVoiceChannel({
channelId: voicechannelId,
guildId: guildId,
selfDeaf: true,
adapterCreator: message.guild.voiceAdapterCreator,
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
const resource = createAudioResource('/audio.mp3', { inlineVolume: true })
const subscription = connection.subscribe(player);
player.play(resource);
});

client.login(process.env.BOT_TOKEN);
2 Replies
d.js toolkit
d.js toolkit2w 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!
JuicyM0N
JuicyM0N2w ago
Bot does join the voice channel