mirror of
https://github.com/danbulant/discord.js
synced 2026-07-06 03:31:03 +00:00
Webpack build for branch master: e124ada962
This commit is contained in:
parent
71ea0b0785
commit
0d0f47d8b8
1 changed files with 3 additions and 1 deletions
|
|
@ -17211,13 +17211,15 @@ class DiscordAPIError extends Error {
|
||||||
/**
|
/**
|
||||||
* Flattens an errors object returned from the API into an array.
|
* Flattens an errors object returned from the API into an array.
|
||||||
* @param {Object} obj Discord errors object
|
* @param {Object} obj Discord errors object
|
||||||
* @param {string} [key] idklol
|
* @param {string} [key] Used internally to determine key names of nested fields
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
*/
|
*/
|
||||||
static flattenErrors(obj, key = '') {
|
static flattenErrors(obj, key = '') {
|
||||||
let messages = [];
|
let messages = [];
|
||||||
|
|
||||||
for (const k of Object.keys(obj)) {
|
for (const k of Object.keys(obj)) {
|
||||||
const newKey = key ? isNaN(k) ? `${key}.${k}` : `${key}[${k}]` : k;
|
const newKey = key ? isNaN(k) ? `${key}.${k}` : `${key}[${k}]` : k;
|
||||||
|
|
||||||
if (obj[k]._errors) {
|
if (obj[k]._errors) {
|
||||||
messages.push(`${newKey}: ${obj[k]._errors.map(e => e.message).join(' ')}`);
|
messages.push(`${newKey}: ${obj[k]._errors.map(e => e.message).join(' ')}`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue