How would I use two different versions of discord.js | Discord.js Bot

Viewed 4322

I want to use the following versions of discord.js for my discord bot:

discord.js v11.6.4 discord.js v12.4.1

I've tried installing each of them one after the other but to no avail.

first
npm i discord.js@11.6.4
then
npm i discord.js@12.4.1

Is there a way to distinct discordv11 from v12 in the package.json and use both modules in one bot?

5 Answers

You need to use npm's aliases feature (note that its only available from npm v6.9.0)

npm install discord.js11@npm:discord.js@11.6.4
npm install discord.js12@npm:discord.js@12.4.1

then you can access it as

const discord11 = require('discord.js11')
const discord12 = require('discord.js12')

Also I don't know why your using discord.js v11, v12 should have full coverage and more, your probably better off using just djs v12

Open your package.json and add:

"dependencies": {
   "DiscordJS11": "npm:discord.js@11.6.4",
   "DiscordJS12": "npm:discord.js@12.4.1"
}

Then do:

npm install

This seems to be a bad practice. Imagine there are breaking changes in DiscordJs 11 to 12 with DiscordAPI. I guess you want to work with new features from v12, maybe it's better to compromise with existing stuff or rewrite v11 code to v12. I hope there aren't much of any breaking changes in v11 to v12, v13 had a lot of breaking changes though

You can install discord.js-v11 and discord.js-v12 packages in npm.

In terminal/cmd:

npm install discord.js-v11

In the code:

const { Client, Intents } = require('discord.js-v11');
// code...

It also works with V12. Just write v12 instead of v11.

Hmm You Can Use Verison 12 this verison available Features Verison 11

npm install discord.js@v12
Related