Not hearing audio

Any idea why?
// Load up the discord.js library
const glob = require("glob")
// This is your client. Some people call it `bot`, some people call it `self`,
// some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
// this is what we're refering to. Your client.
const { Client, Collection, GatewayIntentBits, EmbedBuilder, AttachmentBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Events } = require('discord.js');
const dir = '/home/gibigbig/podcast/podcasts';
const fs = require('fs');
const {
joinVoiceChannel,
createAudioPlayer,
createAudioResource,
entersState,
StreamType,
AudioPlayerStatus,
VoiceConnectionStatus,
} = require('@discordjs/voice');

const player = createAudioPlayer();

player.on(AudioPlayerStatus.Playing, (oldState, newState) => {
console.log('Audio player is in the Playing state!');
});

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


// Here we load the config.json file that contains our token and our prefix values.
const config = require("./config.json");
// config.token contains the bot's token
// config.prefix contains the message prefix.

function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}

function play(connection, files, count, channel) {
player.play(files[count]);
//const dispatcher = connection.play(files[count]);
console.log(`Playing: ${files[count]}`);
client.user.setActivity(`Playing: ${files[count]}`);
channel.setTopic('♫ Now Playing: "The Art Of Manliness Podcast"')

}

function playSong(files, count) {
console.log(files[count])
const resource = createAudioResource(files[count], {
inputType: StreamType.Arbitrary,
});

player.play(resource);
client.user.setActivity(`Playing: ${files[count]}`);
return entersState(player, AudioPlayerStatus.Playing, 5000);
}


client.on("ready", async () => {
let count = 0
// options is optional
glob(`${dir}/*.mp3`, {}, async (err, files) => {
console.log(files)
shuffle(files)
let channel = await client.channels.cache.get("320802196641808385")

const connection = joinVoiceChannel({
channelId: "320802196641808385",
guildId: "320802196641808384",
adapterCreator: channel.guild.voiceAdapterCreator,
});
playSong(files, count)
});
});




client.login(config.token);
// Load up the discord.js library
const glob = require("glob")
// This is your client. Some people call it `bot`, some people call it `self`,
// some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
// this is what we're refering to. Your client.
const { Client, Collection, GatewayIntentBits, EmbedBuilder, AttachmentBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Events } = require('discord.js');
const dir = '/home/gibigbig/podcast/podcasts';
const fs = require('fs');
const {
joinVoiceChannel,
createAudioPlayer,
createAudioResource,
entersState,
StreamType,
AudioPlayerStatus,
VoiceConnectionStatus,
} = require('@discordjs/voice');

const player = createAudioPlayer();

player.on(AudioPlayerStatus.Playing, (oldState, newState) => {
console.log('Audio player is in the Playing state!');
});

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


// Here we load the config.json file that contains our token and our prefix values.
const config = require("./config.json");
// config.token contains the bot's token
// config.prefix contains the message prefix.

function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}

function play(connection, files, count, channel) {
player.play(files[count]);
//const dispatcher = connection.play(files[count]);
console.log(`Playing: ${files[count]}`);
client.user.setActivity(`Playing: ${files[count]}`);
channel.setTopic('♫ Now Playing: "The Art Of Manliness Podcast"')

}

function playSong(files, count) {
console.log(files[count])
const resource = createAudioResource(files[count], {
inputType: StreamType.Arbitrary,
});

player.play(resource);
client.user.setActivity(`Playing: ${files[count]}`);
return entersState(player, AudioPlayerStatus.Playing, 5000);
}


client.on("ready", async () => {
let count = 0
// options is optional
glob(`${dir}/*.mp3`, {}, async (err, files) => {
console.log(files)
shuffle(files)
let channel = await client.channels.cache.get("320802196641808385")

const connection = joinVoiceChannel({
channelId: "320802196641808385",
guildId: "320802196641808384",
adapterCreator: channel.guild.voiceAdapterCreator,
});
playSong(files, count)
});
});




client.login(config.token);
4 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
gibigbig
gibigbigOP2y ago
discordjs 14.8
"dependencies": {
"@discordjs/opus": "^0.5.3",
"@discordjs/voice": "^0.16.0",
"bufferutil": "^4.0.3",
"discord.js": "14.8",
"erlpack": "github:discord/erlpack",
"ffmepg": "^0.0.2-security",
"fs": "^0.0.1-security",
"glob": "^7.1.7",
"libsodium-wrappers": "^0.7.11",
"sodium": "^3.0.2",
"utf-8-validate": "^5.0.5",
"zlib-sync": "^0.1.7"
}
"dependencies": {
"@discordjs/opus": "^0.5.3",
"@discordjs/voice": "^0.16.0",
"bufferutil": "^4.0.3",
"discord.js": "14.8",
"erlpack": "github:discord/erlpack",
"ffmepg": "^0.0.2-security",
"fs": "^0.0.1-security",
"glob": "^7.1.7",
"libsodium-wrappers": "^0.7.11",
"sodium": "^3.0.2",
"utf-8-validate": "^5.0.5",
"zlib-sync": "^0.1.7"
}
orbyfied
orbyfied2y ago
lmao
182exe
182exe2y ago
//some might call it "cootchie"
//some might call it "cootchie"
cant ignore that shit lmao its too funny
Want results from more Discord servers?
Add your server