Bug With difference() Method in Collections

Hi, if I am understanding the documentation correctly, there appears to be a bug with the difference() method of the collections class. The example given and the descriptions states that the method should return a new collection showing what is present in the first collection, but not the second. However when I try to run it, it first returns what doesn't exists in the first collection and then what does exists. Given Example
const col1 = new Collection([['a', 1], ['b', 2]]);
const col2 = new Collection([['a', 1], ['c', 3]]);
console.log(col1.difference(col2));
// => Collection { 'b' => 2 }
console.log(col2.difference(col1));
// => Collection { 'c' => 3 }
const col1 = new Collection([['a', 1], ['b', 2]]);
const col2 = new Collection([['a', 1], ['c', 3]]);
console.log(col1.difference(col2));
// => Collection { 'b' => 2 }
console.log(col2.difference(col1));
// => Collection { 'c' => 3 }
My Code
const { Collection } = require("discord.js");

const col1 = new Collection([
["a", 1],
["b", 2],
]);
const col2 = new Collection([
["a", 1],
["c", 3],
]);
console.log(col1.difference(col2));
// => Collection { 'c' => 3, 'b' => 2 }
console.log(col2.difference(col1));
// => Collection { 'b' => 2, 'c' => 3 }
const { Collection } = require("discord.js");

const col1 = new Collection([
["a", 1],
["b", 2],
]);
const col2 = new Collection([
["a", 1],
["c", 3],
]);
console.log(col1.difference(col2));
// => Collection { 'c' => 3, 'b' => 2 }
console.log(col2.difference(col1));
// => Collection { 'b' => 2, 'c' => 3 }
D.js Version: [email protected]
6 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Kinect3000
Kinect30008mo ago
Can you run npm ls @discordjs/collection?
Arib Alam
Arib AlamOP8mo ago
├── @discordjs/[email protected]
├─┬ @discordjs/[email protected]
│ └── @discordjs/[email protected]
└─┬ @discordjs/[email protected]
└── @discordjs/[email protected]
├── @discordjs/[email protected]
├─┬ @discordjs/[email protected]
│ └── @discordjs/[email protected]
└─┬ @discordjs/[email protected]
└── @discordjs/[email protected]
Kinect3000
Kinect30008mo ago
d.js still using v1.5.3
Arib Alam
Arib AlamOP8mo ago
So there a way to update it? I tried npm i discord.js
Kinect3000
Kinect30008mo ago
No I mean, you could override it to use v2, not sure if that would break other stuff tho I’m not too familiar w/ the changes in the collection package
Want results from more Discord servers?
Add your server