Search code examples
javascriptnode.jsdiscord.jsvoice

'MODULE_NOT_FOUND' in discord.js v13 audio/music bot


I have this simple Music Bot for me and my friends, but after upgrading to v13 of discord.js some things just don´t work anymore... I already changed some things up just like the discord.js guide tels you to do. Someone got an idea what is wrong here??

const ytdl = require('ytdl-core');
const Music = require('discordjs/voice');

console.log("is this working");

//  PLAYER
 client.on("messageCreate", async message => {

  if(message.content == 'goplay') {
  const url = args[0];
  if(!url) return message.channel.send('no url');


  const stream = ytdl(url, { filter: 'audioonly'});

  const channel = message.member.voice.channel;

  const player = Music.createAudioPlayer();
  const ressource = Music.createAudioResource(stream);

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

  player.play(ressource)
  connection.subscribe(player);

  }
});

here is the error message


Solution

  • That looks like a package.json error. Make sure you have a package.json created.

    Use the command npm init, and fill out the needed information, to have it automatically create everything use npm init -y (and then make sure to install all of your npm packages)