Skip to content
Advertisement

Discord.js v13 code breaks when upgrading to v14

I’ve just updated my discord.js from v13 to v14 and there are many errors.

Errors with intents:

JavaScript

Errors with interactions:

JavaScript

Errors with channels:

JavaScript

Errors with builders and embeds:

JavaScript

Errors with enums:

JavaScript

Advertisement

Answer

Discord.js v14 includes many breaking changes. It now requires Node 16.9 or higher to use, so make sure you upgrade to the latest LTS version.

This version of v14 uses the Discord API v10.

Errors with intents:

JavaScript

For a full list of GatewayIntentBits, you can read this answer.

Errors with interactions:

Some interaction type guards have been removed. You can compare interaction.type against the InteractionType enum instead.

JavaScript

Errors with channels:

Some channel type guards have been removed. To narrow channels, you can compare channel.type to a ChannelType enum instead.

JavaScript

For a full list of ChannelTypes, you can read this answer.

Also, there are some new type guards:

JavaScript

Errors with builders and embeds:

MessageEmbed has been renamed to EmbedBuilder.

JavaScript

MessageComponents have been renamed; they no longer have the Message prefix and now have a Builder suffix.

JavaScript

Errors with enums:

Any areas that used to accept a string or number type for an enum parameter will now only accept exclusively numbers.

JavaScript

Errors with activity types: setPresence activity type in discord.js v14 can only be set to “PLAYING”

If message.content doesn’t have any value, add the GatewayIntentBits.MessageContent enum to your intents array

For more breaking changes, you can visit the discord.js guide: https://discordjs.guide/additional-info/changes-in-v14.html

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement