awaitAvailability in guild struct

This commit is contained in:
Radoslaw Partyka 2021-01-01 16:54:33 +01:00
parent 6e8af1f7da
commit c322c25fb0

View file

@ -290,6 +290,24 @@ export class Guild extends Base {
resolve(this) resolve(this)
}) })
} }
/**
* Fulfills promise when guild becomes available
* @param delay the delay between checking guild availability
*/
async awaitAvailiable(
delay: number = 1000
): Promise<void> {
const promise1 = new Promise((resolve, reject) => {
while(true) {
await new Promise(reso => setTimeout(reso, delay))
if(!this.unavailable) {
resolve()
break;
}
}
});
}
} }
export class GuildIntegration extends Base { export class GuildIntegration extends Base {