Music bot not working?

Hello, i’m making a bot for my discord server. The music function used to work before, but now it doesn’t. The bot has a green circle like it is playing music but i don’t seem to hear anything.
My play function is

function play(guild, song) {
const serverQueue = queue.get(guild.id);
if (!song) {
serverQueue.voiceChannel.leave();
queue.delete(guild.id);
return;
}
const dispatcher = serverQueue.connection
.playStream(ytdl(song.url,{filter: “audioonly”}),{seek: 0,
passes: 2, //can be increased to reduce packetloss at the expense of upload bandwidth, 4-5 should be lossless at the expense of 4-5x upload
volume: 0.5})
.on(“finish”, () => {
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
})
.on(“error”, error => console.error(error));

  serverQueue.textChannel.send("Playing: **" + song.title + "**");
}

I don’t get any error on the console

Update discordjs, that solved the issue for me once. Also youtube may be blocking your bot if you use it a lot.

When updating it i get an error

/rbd/pnpm-volume/9d3b317e-46de-4321-91aa-bbc8c2baf5f4/node_modules/.registry.npmjs.org/discord.js/12.1.1/node_modules/discord.js/src/client/Client.js:41

5:03 PM

} catch {

It worked before updating discord.js

Hmmm…can I see more information about the error. I need to know what type of error it is.

/rbd/pnpm-volume/9d3b317e-46de-4321-91aa-bbc8c2baf5f4/node_modules/.registry.npmjs.org/discord.js/12.1.1/node_modules/discord.js/src/client/Client.js:41

5:03 PM

} catch {

5:03 PM

^

5:03 PM

5:03 PM

SyntaxError: Unexpected token {

5:03 PM

at createScript (vm.js:80:10)

5:03 PM

at Object.runInThisContext (vm.js:139:10)

5:03 PM

at Module._compile (module.js:617:28)

5:03 PM

at Object.Module._extensions…js (module.js:664:10)

5:03 PM

at Module.load (module.js:566:32)

5:03 PM

at tryModuleLoad (module.js:506:12)

5:03 PM

at Function.Module._load (module.js:498:3)

5:03 PM

at Module.require (module.js:597:17)

5:03 PM

at require (internal/module.js:11:18)

5:03 PM

at Object. (/rbd/pnpm-volume/9d3b317e-46de-4321-91aa-bbc8c2baf5f4/node_modules/.registry.npmjs.org/discord.js/12.1.1/node_modules/discord.js/src/index.js:8:11)

5:03 PM

I fixed the problem, it was the node.js version. But now client.guilds.get is undefined

1 Like

It also has to use client.users.cache.size, it used client.users.size before

The new version has deleted a lot of old functions :confused:

It’s client.cache.get, etc

They switched to things called managers which means now everything like channels is in the .cache portion. Also instead of channels.createChannel it’s like channels.cache.create

I fixed this by creating a new bot with the lastest version (so i don’t rewrite all my code) And it is working pretty well.