mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 04:56:07 +00:00
* perf: optimize members cache * feat: components V2 (#337) * feat: components v2 * fix: build * chore: apply formatting * refactor(components): some types * refactor(types): replace TopLevelComponents with APITopLevelComponent in REST * fix: unify components * refactor(TextDisplay): rename content method to setContent for clarity * refactor(builders): add missing builder from component * fix: touche * feat(webhook): webhook params for components v2 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: use protected instead of private * fix(editOrReply): accept flags when editing message * feat: add onBeforeMiddlewares and onBeforeOptions (#338) * chore: package version --------- Co-authored-by: MARCROCK22 <marcos22dev@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com>
61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
import type {
|
|
ComponentInteraction,
|
|
ModalSubmitInteraction,
|
|
StringSelectMenuInteraction,
|
|
} from '../structures/Interaction';
|
|
import type { ActionRow } from './ActionRow';
|
|
import type { Button } from './Button';
|
|
import type { Container } from './Container';
|
|
import type { File } from './File';
|
|
import type { MediaGallery } from './MediaGallery';
|
|
import type { TextInput } from './Modal';
|
|
import type { Section } from './Section';
|
|
import type { BuilderSelectMenus } from './SelectMenu';
|
|
import type { Separator } from './Separator';
|
|
import type { TextDisplay } from './TextDisplay';
|
|
import type { Thumbnail } from './Thumbnail';
|
|
|
|
export type ComponentCallback<
|
|
T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction,
|
|
> = (interaction: T, stop: ComponentStopCallback, refresh: ComponentRefreshCallback) => any;
|
|
export type ComponentOnErrorCallback<
|
|
T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction,
|
|
> = (interaction: T, error: unknown, stop: ComponentStopCallback, refresh: ComponentRefreshCallback) => any;
|
|
export type ComponentFilterCallback<T = ComponentInteraction> = (interaction: T) => any;
|
|
export type ComponentStopCallback = (
|
|
reason: 'messageDelete' | 'channelDelete' | 'guildDelete' | 'idle' | 'timeout' | (string & {}) | undefined,
|
|
refresh: ComponentRefreshCallback,
|
|
) => any;
|
|
export type ComponentRefreshCallback = () => any;
|
|
export type ModalSubmitCallback<T = ModalSubmitInteraction> = (interaction: T) => any;
|
|
export type ButtonLink = Omit<Button, 'setCustomId'>;
|
|
export type ButtonID = Omit<Button, 'setURL'>;
|
|
|
|
export type MessageBuilderComponents = FixedComponents<Button> | BuilderSelectMenus;
|
|
export type ModalBuilderComponents = TextInput;
|
|
export type ActionBuilderComponents = MessageBuilderComponents | TextInput;
|
|
|
|
export type BuilderComponents =
|
|
| ActionRow
|
|
| ActionBuilderComponents
|
|
| Section<Button | Thumbnail>
|
|
| Thumbnail
|
|
| TextDisplay
|
|
| Container
|
|
| Separator
|
|
| MediaGallery
|
|
| File
|
|
| TextInput;
|
|
|
|
export type TopLevelBuilders = Exclude<BuilderComponents, Thumbnail | TextInput>;
|
|
|
|
export type FixedComponents<T = Button> = T extends Button ? ButtonLink | ButtonID : T;
|
|
export interface ListenerOptions {
|
|
timeout?: number;
|
|
idle?: number;
|
|
filter?: ComponentFilterCallback;
|
|
onPass?: ComponentFilterCallback;
|
|
onStop?: ComponentStopCallback;
|
|
onError?: ComponentOnErrorCallback;
|
|
}
|