mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
refactor: update waitFor method to improve promise handling and timeout logic
This commit is contained in:
parent
35f1904920
commit
cccf1ea2c4
@ -90,20 +90,17 @@ export class Modal<T extends ModalBuilderComponents = TextInput> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
waitFor(func: ModalSubmitCallback, timeout: number): this {
|
waitFor(timeout?: number): Promise<ModalSubmitInteraction<boolean> | null> {
|
||||||
this.run(
|
return new Promise<ModalSubmitInteraction<boolean> | null>(res => {
|
||||||
interaction =>
|
this.run(interaction => {
|
||||||
new Promise(resolve => {
|
res(interaction);
|
||||||
const timer = setTimeout(() => {
|
});
|
||||||
resolve(null);
|
if (timeout && timeout > 0) {
|
||||||
}, timeout);
|
setTimeout(() => {
|
||||||
func(interaction).then((data: ModalSubmitInteraction) => {
|
res(null);
|
||||||
clearTimeout(timer);
|
}, timeout);
|
||||||
resolve(data);
|
}
|
||||||
});
|
});
|
||||||
}),
|
|
||||||
);
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user