Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(components): setX should take rest parameters #7461

Merged
merged 2 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/builders/__tests__/components/actionRow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Action Row Components', () => {
describe('Assertion Tests', () => {
test('GIVEN valid components THEN do not throw', () => {
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', () => {
Expand Down Expand Up @@ -84,10 +84,10 @@ describe('Action Row Components', () => {
.setCustomId('1234')
.setMaxValues(10)
.setMinValues(12)
.setOptions([
.setOptions(
new SelectMenuOption().setLabel('one').setValue('one'),
new SelectMenuOption().setLabel('two').setValue('two'),
]);
);

expect(new ActionRow().addComponents(button).toJSON()).toEqual(rowWithButtonData);
expect(new ActionRow().addComponents(selectMenu).toJSON()).toEqual(rowWithSelectMenuData);
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/ActionRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ActionRow<T extends ActionRowComponent = ActionRowComponent> extend
* Sets the components in this action row
* @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);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class UnsafeSelectMenuComponent extends Component<
* Sets the options 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);
return this;
}
Expand Down