mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +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';
|
||||
|
||||
const { SelectMenuBuilder: BuildersSelectMenu, isJSONEncodable } = require('@discordjs/builders');
|
||||
const { SelectMenuBuilder: BuildersSelectMenu, isJSONEncodable, normalizeArray } = require('@discordjs/builders');
|
||||
const Transformers = require('../util/Transformers');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
@@ -23,12 +23,12 @@ class SelectMenuBuilder extends BuildersSelectMenu {
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
addOptions(options) {
|
||||
addOptions(...options) {
|
||||
return super.addOptions(
|
||||
options.map(({ emoji, ...option }) => ({
|
||||
normalizeArray(options).map(({ emoji, ...option }) => ({
|
||||
...option,
|
||||
emoji: emoji && typeof emoji === 'string' ? Util.parseEmoji(emoji) : emoji,
|
||||
})),
|
||||
@@ -37,12 +37,12 @@ class SelectMenuBuilder extends BuildersSelectMenu {
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
setOptions(options) {
|
||||
setOptions(...options) {
|
||||
return super.setOptions(
|
||||
options.map(({ emoji, ...option }) => ({
|
||||
normalizeArray(options).map(({ emoji, ...option }) => ({
|
||||
...option,
|
||||
emoji: emoji && typeof emoji === 'string' ? Util.parseEmoji(emoji) : emoji,
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user