mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Allow deleting reminders
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
Reference in New Issue
Block a user