Discord.js v12 code breaks when upgrading to v13

Discord.js v13 has a lot of changes, and those are only a few. Before updating to v13, you should change the following things

//member.hasPermission("SEND_MESSAGES")
member.permissions.has("SEND_MESSAGES")

//channel.send(someEmbed) / channel.send({embed: someEmbed})
channel.send({ embeds: [someEmbed] }) //make sure it's an array!

//client.on("message", msg => {})
client.on("messageCreate", msg => {})

//channel.send(user)
channel.send(user.toString())

//const client = new Client()
const { Intents, Client } = require("discord.js")
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]}) //more intents may be provided

//await channel.join()
const { joinVoiceChannel } = require("@discordjs/voice") //requires installation
joinVoiceChannel({
  channelId: channel.id,
  guildId: guild.id,
  adapterCreator: guild.voiceAdapterCreator
})

There are some more changes. You can see them in the guide

Leave a Comment