static function flattenErrors($obj, $key = '') {
        $messages = array();
        
        foreach($obj as $k => $val) {
            if($k === 'message') {
                continue;
            }
            
            $newKey = $k;
            if($key) {
                if(\is_numeric($k)) {
                    $newKey = $key.'.'.$k;
                } else {
                    $newKey = $key.'['.$k.']';
                }
            }
            
            if(isset($val['_errors'])) {
                $messages[] = $newKey.': '.\implode(' ', \array_map(function ($element) {
                    return $element['message'];
                }, $val['_errors']));
            } else if(isset($val['code']) || isset($val['message'])) {
                $messages[] = \trim(($val['code'] ?? '').': '.($val['message'] ?? ''));
            } else if(\is_array($val)) {
                $messages = \array_merge($messages, self::flattenErrors($val, $newKey));
            } else {
                $messages[] = $val;
            }
        }

        return $messages;
    }
static function flattenErrors($obj, $key = '') {
        $messages = array();
        
        foreach($obj as $k => $val) {
            if($k === 'message') {
                continue;
            }
            
            $newKey = $k;
            if($key) {
                if(\is_numeric($k)) {
                    $newKey = $key.'.'.$k;
                } else {
                    $newKey = $key.'['.$k.']';
                }
            }
            
            if(isset($val['_errors'])) {
                $messages[] = $newKey.': '.\implode(' ', \array_map(function ($element) {
                    return $element['message'];
                }, $val['_errors']));
            } else if(isset($val['code']) || isset($val['message'])) {
                $messages[] = \trim(($val['code'] ?? '').': '.($val['message'] ?? ''));
            } else if(\is_array($val)) {
                $messages = \array_merge($messages, self::flattenErrors($val, $newKey));
            } else {
                $messages[] = $val;
            }
        }

        return $messages;
    }
static function flattenErrors ( $ obj , $ key = '' ) { $ messages = array ( ) ; foreach ( $ obj as $ k => $ val ) { if ( $ k === 'message' ) { continue ; } $ newKey = $ k ; if ( $ key ) { if ( \ is_numeric ( $ k ) ) { $ newKey = $ key . '.' . $ k ; } else { $ newKey = $ key . '[' . $ k . ']' ; } } if ( isset ( $ val [ '_errors' ] ) ) { $ messages [ ] = $ newKey . ': ' . \ implode ( ' ' , \ array_map ( function ( $ element ) { return $ element [ 'message' ] ; } , $ val [ '_errors' ] ) ) ; } else if ( isset ( $ val [ 'code' ] ) || isset ( $ val [ 'message' ] ) ) { $ messages [ ] = \ trim ( ( $ val [ 'code' ] ?? '' ) . ': ' . ( $ val [ 'message' ] ?? '' ) ) ; } else if ( \ is_array ( $ val ) ) { $ messages = \ array_merge ( $ messages , self :: flattenErrors ( $ val , $ newKey ) ) ; } else { $ messages [ ] = $ val ; } } return $ messages ; }
Flattens an errors object returned from the API into an array.
@param array   $obj  Discord error object
@param string  $key  Used internally to determine key names of nested fields
@return string[]
@internal
Flattens an errors object returned from the API into an array .