mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 21:13:30 +01:00
fix(components): setX should take rest parameters (#7461)
This commit is contained in:
@@ -5,7 +5,7 @@ describe('Action Row Components', () => {
|
|||||||
describe('Assertion Tests', () => {
|
describe('Assertion Tests', () => {
|
||||||
test('GIVEN valid components THEN do not throw', () => {
|
test('GIVEN valid components THEN do not throw', () => {
|
||||||
expect(() => new ActionRow().addComponents(new ButtonComponent())).not.toThrowError();
|
expect(() => new ActionRow().addComponents(new ButtonComponent())).not.toThrowError();
|
||||||
expect(() => new ActionRow().setComponents([new ButtonComponent()])).not.toThrowError();
|
expect(() => new ActionRow().setComponents(new ButtonComponent())).not.toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN valid JSON input THEN valid JSON output is given', () => {
|
test('GIVEN valid JSON input THEN valid JSON output is given', () => {
|
||||||
@@ -84,10 +84,10 @@ describe('Action Row Components', () => {
|
|||||||
.setCustomId('1234')
|
.setCustomId('1234')
|
||||||
.setMaxValues(10)
|
.setMaxValues(10)
|
||||||
.setMinValues(12)
|
.setMinValues(12)
|
||||||
.setOptions([
|
.setOptions(
|
||||||
new SelectMenuOption().setLabel('one').setValue('one'),
|
new SelectMenuOption().setLabel('one').setValue('one'),
|
||||||
new SelectMenuOption().setLabel('two').setValue('two'),
|
new SelectMenuOption().setLabel('two').setValue('two'),
|
||||||
]);
|
);
|
||||||
|
|
||||||
expect(new ActionRow().addComponents(button).toJSON()).toEqual(rowWithButtonData);
|
expect(new ActionRow().addComponents(button).toJSON()).toEqual(rowWithButtonData);
|
||||||
expect(new ActionRow().addComponents(selectMenu).toJSON()).toEqual(rowWithSelectMenuData);
|
expect(new ActionRow().addComponents(selectMenu).toJSON()).toEqual(rowWithSelectMenuData);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export class ActionRow<T extends ActionRowComponent = ActionRowComponent> extend
|
|||||||
* Sets the components in this action row
|
* Sets the components in this action row
|
||||||
* @param components The components to set this row to
|
* @param components The components to set this row to
|
||||||
*/
|
*/
|
||||||
public setComponents(components: T[]) {
|
public setComponents(...components: T[]) {
|
||||||
this.components.splice(0, this.components.length, ...components);
|
this.components.splice(0, this.components.length, ...components);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export class UnsafeSelectMenuComponent extends Component<
|
|||||||
* Sets the options on this select menu
|
* Sets the options on this select menu
|
||||||
* @param options The options to set on this select menu
|
* @param options The options to set on this select menu
|
||||||
*/
|
*/
|
||||||
public setOptions(options: UnsafeSelectMenuOption[]) {
|
public setOptions(...options: UnsafeSelectMenuOption[]) {
|
||||||
this.options.splice(0, this.options.length, ...options);
|
this.options.splice(0, this.options.length, ...options);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user