Skip to content

Commit

Permalink
fix(polls): extend timeout for sending several messages
Browse files Browse the repository at this point in the history
Extend timeout for sending several messages should help tests to
have correct order of messages. If we still have some issues with this,
we shuld consider to add proper message queue
  • Loading branch information
sogehige committed Feb 11, 2019
1 parent 1e3c4cc commit c45c286
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/bot/systems/polls.ts
Expand Up @@ -142,7 +142,7 @@ class Polls extends System {
} else {
global.commons.sendMessage(`#vote${Number(index) + 1} - ${option} - ${votesCount} ${global.commons.getLocalizedName(votesCount, 'systems.polls.votes')}, ${percentage}%`, opts.sender);
}
}, 100 * (Number(index) + 1));
}, 300 * (Number(index) + 1));
}
}
} catch (e) {
Expand Down Expand Up @@ -180,7 +180,7 @@ class Polls extends System {
for (const index of Object.keys(options)) {
setTimeout(() => {
if (type === 'normal') { global.commons.sendMessage(this.settings.commands['!vote'] + ` ${(Number(index) + 1)} => ${options[index]}`, opts.sender); } else { global.commons.sendMessage(`#vote${(Number(index) + 1)} => ${options[index]}`, opts.sender); }
}, 100 * (Number(index) + 1));
}, 300 * (Number(index) + 1));
}

this.lastTimeRemind = Date.now();
Expand All @@ -199,7 +199,7 @@ class Polls extends System {
for (const index of Object.keys(cVote.options)) {
setTimeout(() => {
if (cVote.type === 'normal') { global.commons.sendMessage(this.settings.commands['!poll open'] + ` ${index} => ${cVote.options[index]}`, opts.sender); } else { global.commons.sendMessage(`#vote${(Number(index) + 1)} => ${cVote.options[index]}`, opts.sender); }
}, 100 * (Number(index) + 1));
}, 300 * (Number(index) + 1));
}
break;
default:
Expand Down Expand Up @@ -366,7 +366,7 @@ class Polls extends System {
for (const index of Object.keys(vote.options)) {
setTimeout(() => {
if (vote.type === 'normal') { global.commons.sendMessage(this.settings.commands['!vote'] + ` ${(Number(index) + 1)} => ${vote.options[index]}`, global.commons.getOwner()); } else { global.commons.sendMessage(`#vote${(Number(index) + 1)} => ${vote.options[index]}`, global.commons.getOwner()); }
}, 100 * (Number(index) + 1));
}, 300 * (Number(index) + 1));
}
}
}
Expand Down

0 comments on commit c45c286

Please sign in to comment.