diff options
| author | Max Isom <[email protected]> | 2020-03-19 19:16:07 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-19 19:16:07 -0500 |
| commit | f25467a41db64b239eb3f248f4be7dbecec0f14f (patch) | |
| tree | ad7babf6e15c5a0593fcb7e073ad9a05a06decce /src/utils | |
| parent | 4659717e5f314d061f9748331c79d507df971f7f (diff) | |
| download | muse-f25467a41db64b239eb3f248f4be7dbecec0f14f.tar.xz muse-f25467a41db64b239eb3f248f4be7dbecec0f14f.zip | |
Small bug fixes
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/loading-message.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/utils/loading-message.ts b/src/utils/loading-message.ts index cf48d95..dd3e9b9 100644 --- a/src/utils/loading-message.ts +++ b/src/utils/loading-message.ts @@ -1,11 +1,14 @@ import {TextChannel, Message} from 'discord.js'; import delay from 'delay'; +const INITAL_DELAY = 500; +const PERIOD = 500; + export default class { + public isStopped = true; private readonly channel: TextChannel; private readonly text: string; private msg!: Message; - private isStopped = false; constructor(channel: TextChannel, text = 'cows! count \'em') { this.channel = channel; @@ -15,22 +18,25 @@ export default class { async start(): Promise<void> { this.msg = await this.channel.send(this.text); - const period = 500; - const icons = ['🐮', '🐴', '🐄']; const reactions = []; let i = 0; let isRemoving = false; + + this.isStopped = false; + (async () => { + await delay(INITAL_DELAY); + while (!this.isStopped) { if (reactions.length === icons.length) { isRemoving = true; } // eslint-disable-next-line no-await-in-loop - await delay(period); + await delay(PERIOD); if (isRemoving) { const reactionToRemove = reactions.shift(); |
