diff --git a/src/builders/Modal.ts b/src/builders/Modal.ts index 150e037..4618014 100644 --- a/src/builders/Modal.ts +++ b/src/builders/Modal.ts @@ -90,20 +90,17 @@ export class Modal { 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; + waitFor(timeout?: number): Promise | null> { + return new Promise | null>(res => { + this.run(interaction => { + res(interaction); + }); + if (timeout && timeout > 0) { + setTimeout(() => { + res(null); + }, timeout); + } + }); } /**