aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/loading-message.ts14
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();