mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat: modal#waitFor
This commit is contained in:
parent
6e037ae964
commit
35f1904920
@ -1,4 +1,5 @@
|
||||
import type { RestOrArray } from '../common';
|
||||
import { ModalSubmitInteraction } from '../structures';
|
||||
import {
|
||||
type APIActionRowComponent,
|
||||
type APIModalInteractionResponseCallbackData,
|
||||
@ -89,6 +90,22 @@ export class Modal<T extends ModalBuilderComponents = TextInput> {
|
||||
return this;
|
||||
}
|
||||
|
||||
waitFor(func: ModalSubmitCallback, timeout: number): this {
|
||||
this.run(
|
||||
interaction =>
|
||||
new Promise(resolve => {
|
||||
const timer = setTimeout(() => {
|
||||
resolve(null);
|
||||
}, timeout);
|
||||
func(interaction).then((data: ModalSubmitInteraction) => {
|
||||
clearTimeout(timer);
|
||||
resolve(data);
|
||||
});
|
||||
}),
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the modal to JSON format.
|
||||
* @returns The modal data in JSON format.
|
||||
|
Loading…
x
Reference in New Issue
Block a user