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
Code
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: yesOpus 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: yesCode
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);