mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
fix: select menu options to accept both rest and array (#8032)
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { SelectMenuBuilder: BuildersSelectMenu, isJSONEncodable } = require('@discordjs/builders');
|
const { SelectMenuBuilder: BuildersSelectMenu, isJSONEncodable, normalizeArray } = require('@discordjs/builders');
|
||||||
const Transformers = require('../util/Transformers');
|
const Transformers = require('../util/Transformers');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
@@ -23,12 +23,12 @@ class SelectMenuBuilder extends BuildersSelectMenu {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds options to this select menu
|
* Adds options to this select menu
|
||||||
* @param {APISelectMenuOption[]} options The options to add to this select menu
|
* @param {RestOrArray<APISelectMenuOption>} options The options to add to this select menu
|
||||||
* @returns {SelectMenuBuilder}
|
* @returns {SelectMenuBuilder}
|
||||||
*/
|
*/
|
||||||
addOptions(options) {
|
addOptions(...options) {
|
||||||
return super.addOptions(
|
return super.addOptions(
|
||||||
options.map(({ emoji, ...option }) => ({
|
normalizeArray(options).map(({ emoji, ...option }) => ({
|
||||||
...option,
|
...option,
|
||||||
emoji: emoji && typeof emoji === 'string' ? Util.parseEmoji(emoji) : emoji,
|
emoji: emoji && typeof emoji === 'string' ? Util.parseEmoji(emoji) : emoji,
|
||||||
})),
|
})),
|
||||||
@@ -37,12 +37,12 @@ class SelectMenuBuilder extends BuildersSelectMenu {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the options on this select menu
|
* Sets the options on this select menu
|
||||||
* @param {APISelectMenuOption[]} options The options to set on this select menu
|
* @param {RestOrArray<APISelectMenuOption>} options The options to set on this select menu
|
||||||
* @returns {SelectMenuBuilder}
|
* @returns {SelectMenuBuilder}
|
||||||
*/
|
*/
|
||||||
setOptions(options) {
|
setOptions(...options) {
|
||||||
return super.setOptions(
|
return super.setOptions(
|
||||||
options.map(({ emoji, ...option }) => ({
|
normalizeArray(options).map(({ emoji, ...option }) => ({
|
||||||
...option,
|
...option,
|
||||||
emoji: emoji && typeof emoji === 'string' ? Util.parseEmoji(emoji) : emoji,
|
emoji: emoji && typeof emoji === 'string' ? Util.parseEmoji(emoji) : emoji,
|
||||||
})),
|
})),
|
||||||
|
|||||||
Reference in New Issue
Block a user