Marcos Susaña 87cdad0b03
Next: A complete Biscuit rewrite (#131)
* FINALLY WE REACHED AN AGREEMENT

* chore: d-types adapt

* websocket sucks, rest

* changes

* new look for core

* 💀

* fix cdn routes, more structures

Co-authored-by: Free 公園 <FreeAoi@users.noreply.github.com>

* CDN routes

* chore: change to rome

Co-authored-by: Free 公園 <FreeAoi@users.noreply.github.com>

* Oh shit, here we go again

Co-authored-by: Free 公園 <FreeAoi@users.noreply.github.com>

* fixes

* mixin, handler events, ws
Co-authored-by: Yuzu
<yuzudev@users.noreply.github.com>
Co-authored-by: Free 公園 <FreeAoi@users.noreply.github.com>

* change type

* Error system (#133)

* Co-authored-by: Free 公園 <FreeAoi@users.noreply.github.com>

* chore: biscuit rebase

* token leak goes brrrr

* fix: events

* chore: road to raw data

* fix: managers typing

* chore: fix gateway typing

* feat: helpers

* style: linter

* Types for routes (#134)

* typing for routes

* managers

Co-authored-by: Marcos Susaña <marcosjgs03@gmail.com>

* Types for routes (#134)

* I wanna cry

* Next (#136)

* Merge #137

* chore: lineWidth to 140

* chore: README update

---------

Co-authored-by: Yuzu <yuzuru@programmer.net>
Co-authored-by: Free 公園 <FreeAoi@users.noreply.github.com>
Co-authored-by: ThisIsAName <46913407+NejireSupremacy@users.noreply.github.com>
Co-authored-by: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com>
Co-authored-by: MARCROCK22 <marcos22dev@gmail.com>
2023-05-29 22:34:47 -04:00

31 lines
1.0 KiB
TypeScript

import { APIActionRowComponent, APIMessageActionRowComponent, ComponentType, TypeArray } from '@biscuitland/common';
import { MessageComponents, createComponent } from '../Utils';
import { BaseComponent } from './BaseComponent';
export class MessageActionRow<T extends MessageComponents> extends BaseComponent<
APIActionRowComponent<APIMessageActionRowComponent>
> {
constructor({ components, ...data }: Partial<APIActionRowComponent<APIMessageActionRowComponent>>) {
super({ ...data, type: ComponentType.ActionRow });
this.components = (components?.map(createComponent) ?? []) as T[];
}
components: T[];
addComponents(component: TypeArray<T>): this {
this.components.concat(component);
return this;
}
setComponents(component: T[]): this {
this.components = [...component];
return this;
}
toJSON(): APIActionRowComponent<APIMessageActionRowComponent> {
return {
...this.data,
components: this.components.map((c) => c.toJSON())
} as APIActionRowComponent<ReturnType<T['toJSON']>>;
}
}