mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
fix(Util): fix collection import (#6256)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { parse } = require('path');
|
const { parse } = require('path');
|
||||||
|
const { Collection } = require('@discordjs/collection');
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const { Colors, Endpoints } = require('./Constants');
|
const { Colors, Endpoints } = require('./Constants');
|
||||||
const Options = require('./Options');
|
const Options = require('./Options');
|
||||||
@@ -38,9 +39,9 @@ class Util extends null {
|
|||||||
const valueOf = elemIsObj && typeof element.valueOf === 'function' ? element.valueOf() : null;
|
const valueOf = elemIsObj && typeof element.valueOf === 'function' ? element.valueOf() : null;
|
||||||
|
|
||||||
// If it's a Collection, make the array of keys
|
// If it's a Collection, make the array of keys
|
||||||
if (element instanceof require('./Collection')) out[newProp] = Array.from(element.keys());
|
if (element instanceof Collection) out[newProp] = Array.from(element.keys());
|
||||||
// If the valueOf is a Collection, use its array of keys
|
// If the valueOf is a Collection, use its array of keys
|
||||||
else if (valueOf instanceof require('./Collection')) out[newProp] = Array.from(valueOf.keys());
|
else if (valueOf instanceof Collection) out[newProp] = Array.from(valueOf.keys());
|
||||||
// If it's an array, flatten each element
|
// If it's an array, flatten each element
|
||||||
else if (Array.isArray(element)) out[newProp] = element.map(e => Util.flatten(e));
|
else if (Array.isArray(element)) out[newProp] = element.map(e => Util.flatten(e));
|
||||||
// If it's an object with a primitive `valueOf`, use that value
|
// If it's an object with a primitive `valueOf`, use that value
|
||||||
|
|||||||
Reference in New Issue
Block a user