mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
fix: fix crash when decay period is 0
This commit is contained in:
parent
ccd1d3d69e
commit
801cd2630b
2 changed files with 5 additions and 1 deletions
|
@ -161,7 +161,7 @@ export class GuildCounters extends BaseGuildRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
const decayAmountToApply = Math.round((diffFromLastDecayMs / decayPeriodMs) * decayAmount);
|
const decayAmountToApply = Math.round((diffFromLastDecayMs / decayPeriodMs) * decayAmount);
|
||||||
if (decayAmountToApply === 0) {
|
if (decayAmountToApply === 0 || Number.isNaN(decayAmountToApply)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,10 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
||||||
|
|
||||||
const decay = counter.decay;
|
const decay = counter.decay;
|
||||||
const decayPeriodMs = convertDelayStringToMS(decay.every)!;
|
const decayPeriodMs = convertDelayStringToMS(decay.every)!;
|
||||||
|
if (decayPeriodMs === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
pluginData.state.decayTimers.push(
|
pluginData.state.decayTimers.push(
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
decayCounter(pluginData, counterName, decayPeriodMs, decay.amount);
|
decayCounter(pluginData, counterName, decayPeriodMs, decay.amount);
|
||||||
|
|
Loading…
Add table
Reference in a new issue