Allow deleting reminders

This commit is contained in:
Dragon Fire
2020-11-26 11:05:03 -05:00
parent d6a0f4a013
commit 5ddf5798fd
7 changed files with 39 additions and 5 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ const winston = require('winston');
const fs = require('fs');
const path = require('path');
const Redis = require('./Redis');
const TimerManager = require('./timer/TimerManager');
const TimerManager = require('./remind/TimerManager');
const PokemonStore = require('./pokemon/PokemonStore');
const MemePosterClient = require('./MemePoster');
const activities = require('../assets/json/activity');
@@ -1,6 +1,8 @@
module.exports = class TimerManager {
constructor(client) {
Object.defineProperty(this, 'client', { value: client });
this.timeouts = new Map();
}
async fetchAll() {
@@ -23,9 +25,16 @@ module.exports = class TimerManager {
}
}, time);
if (updateRedis) await this.client.redis.hset('timer', { [`${channelID}-${userID}`]: JSON.stringify(data) });
this.timeouts.set(`${channelID}-${userID}`, timeout);
return timeout;
}
deleteTimer(channelID, userID) {
clearTimeout(this.timeouts.get(`${channelID}-${userID}`));
this.timeouts.delete(`${channelID}-${userID}`);
return this.client.redis.hdel('timer', `${channelID}-${userID}`);
}
exists(channelID, userID) {
return this.client.redis.hexists('timer', `${channelID}-${userID}`);
}