refactor: change remaining parameter names

This commit is contained in:
Danial Raza
2023-09-20 22:30:16 +00:00
parent 25c43c2776
commit 0af5e7a38f
2 changed files with 5 additions and 5 deletions

View File

@@ -123,7 +123,7 @@ class ApplicationCommand extends Base {
* The options of this command * The options of this command
* @type {ApplicationCommandOption[]} * @type {ApplicationCommandOption[]}
*/ */
this.options = data.options.map(o => this.constructor.transformOption(o, true)); this.options = data.options.map(opt => this.constructor.transformOption(opt, true));
} else { } else {
this.options ??= []; this.options ??= [];
} }
@@ -577,7 +577,7 @@ class ApplicationCommand extends Base {
[nameLocalizationsKey]: choice.nameLocalizations ?? choice.name_localizations, [nameLocalizationsKey]: choice.nameLocalizations ?? choice.name_localizations,
value: choice.value, value: choice.value,
})), })),
options: option.options?.map(o => this.transformOption(o, received)), options: option.options?.map(opt => this.transformOption(opt, received)),
[channelTypesKey]: option.channelTypes ?? option.channel_types, [channelTypesKey]: option.channelTypes ?? option.channel_types,
[minValueKey]: option.minValue ?? option.min_value, [minValueKey]: option.minValue ?? option.min_value,
[maxValueKey]: option.maxValue ?? option.max_value, [maxValueKey]: option.maxValue ?? option.max_value,

View File

@@ -18,8 +18,8 @@ function flatten(obj, ...props) {
if (!isObject(obj)) return obj; if (!isObject(obj)) return obj;
const objProps = Object.keys(obj) const objProps = Object.keys(obj)
.filter(k => !k.startsWith('_')) .filter(key => !key.startsWith('_'))
.map(k => ({ [k]: true })); .map(key => ({ [key]: true }));
props = objProps.length ? Object.assign(...objProps, ...props) : Object.assign({}, ...props); props = objProps.length ? Object.assign(...objProps, ...props) : Object.assign({}, ...props);
@@ -39,7 +39,7 @@ function flatten(obj, ...props) {
// 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 Collection) out[newProp] = Array.from(valueOf.keys()); else if (valueOf instanceof Collection) out[newProp] = Array.from(valueOf.keys());
// If it's an array, call toJSON function on each element if present, otherwise flatten each element // If it's an array, call toJSON function on each element if present, otherwise flatten each element
else if (Array.isArray(element)) out[newProp] = element.map(e => e.toJSON?.() ?? flatten(e)); else if (Array.isArray(element)) out[newProp] = element.map(elm => elm.toJSON?.() ?? flatten(elm));
// If it's an object with a primitive `valueOf`, use that value // If it's an object with a primitive `valueOf`, use that value
else if (typeof valueOf !== 'object') out[newProp] = valueOf; else if (typeof valueOf !== 'object') out[newProp] = valueOf;
// If it's an object with a toJSON function, use the return value of it // If it's an object with a toJSON function, use the return value of it