danielwerg / r6api.js

🍫 Node.js wrapper around Rainbow Six Siege APIs
https://npm.im/r6api.js
MIT License
111 stars 19 forks source link

TypeError: Cannot read properties of undefined (reading 'join') #80

Closed Turtlepaw closed 2 years ago

Turtlepaw commented 2 years ago
TypeError: Cannot read properties of undefined (reading 'join')
at exports.default (/home/ubuntu/pepperbot/node_modules/r6api.js/dist/methods/getStats.js:128:30)
EndBug commented 2 years ago

Can you post your code that calls getStats()? Seems like you didn't correctly add the ids parameter...

danielwerg commented 2 years ago

As @EndBug said, it's probably that (javascript moment). But to say for sure we need to see snippet of your code where you are using r6api.js

Turtlepaw commented 2 years ago

This was the only part that had join so here it is:

const raw = options && options.raw || false;
    const limit = 7500 - ids.join(',').length; //⭐
    const stats = [...new Set(options && options.categories
            ? options.categories.map(category => constants_1.STATS_CATEGORIES[category]).flat(2)
            : Object.values(constants_1.STATS_CATEGORIES).flat(2))]
        .reduce((acc, cur) => {
        const index = acc.length ? acc.length - 1 : 0;
        const string = acc[index] ? `${acc[index]},${cur}` : cur;
        return string.length <= limit
            ? Object.assign(acc, { [index]: string })
            : [...acc, cur];
    }, []);
danielwerg commented 2 years ago

snippet of your code

ids should always be string[] unless you are providing undefined

EndBug commented 2 years ago

@TurtlePaw The error is coming from the code from this library because the argument you're passing as the ids parameter is not defined. You have to check out the part where you're calling r6api.getStats(), and check if you're passing the parameters according to the docs