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 type { RestOrArray } from '../common';
|
||||||
|
import { ModalSubmitInteraction } from '../structures';
|
||||||
import {
|
import {
|
||||||
type APIActionRowComponent,
|
type APIActionRowComponent,
|
||||||
type APIModalInteractionResponseCallbackData,
|
type APIModalInteractionResponseCallbackData,
|
||||||
@ -89,6 +90,22 @@ export class Modal<T extends ModalBuilderComponents = TextInput> {
|
|||||||
return this;
|
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.
|
* Converts the modal to JSON format.
|
||||||
* @returns The modal data in JSON format.
|
* @returns The modal data in JSON format.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user