diff --git a/src/client/rest/DiscordAPIError.js b/src/client/rest/DiscordAPIError.js index a28e3a8a5..84069bf03 100644 --- a/src/client/rest/DiscordAPIError.js +++ b/src/client/rest/DiscordAPIError.js @@ -18,13 +18,15 @@ class DiscordAPIError extends Error { /** * Flattens an errors object returned from the API into an array. * @param {Object} obj Discord errors object - * @param {string} [key] idklol + * @param {string} [key] Used internally to determine key names of nested fields * @returns {string[]} */ static flattenErrors(obj, key = '') { let messages = []; + for (const k of Object.keys(obj)) { const newKey = key ? isNaN(k) ? `${key}.${k}` : `${key}[${k}]` : k; + if (obj[k]._errors) { messages.push(`${newKey}: ${obj[k]._errors.map(e => e.message).join(' ')}`); } else {