diff --git a/src/commands/slash/conwaysgameoflife.js b/src/commands/slash/conwaysgameoflife.js index b65dfae..c02b613 100644 --- a/src/commands/slash/conwaysgameoflife.js +++ b/src/commands/slash/conwaysgameoflife.js @@ -203,13 +203,17 @@ const moduleFuncs = { const { bot } = context; const { KeyValue } = bot; bot.gameOfLife = { - games: new KeyValue(15 * 60 * 1000), + games: new KeyValue(), createGame(size, id) { const game = new this.GameOfLife(size); - this.games.store(id, { - game, - endTime: new Date().getTime() + 15 * 60 * 1000, - }); + this.games.store( + id, + { + game, + endTime: new Date().getTime() + 15 * 60 * 1000, + }, + 15 * 60 * 1000 + ); return game; }, diff --git a/src/plugins/key_value.js b/src/plugins/key_value.js index 727f2e2..61a3b41 100644 --- a/src/plugins/key_value.js +++ b/src/plugins/key_value.js @@ -1,14 +1,13 @@ function main(context) { const { bot } = context; bot.KeyValue = class { - constructor(time) { - this.time = time; + constructor() { this.map = new Map(); } - store(key, value) { + store(key, value, time) { this.map.set(key, value); - setTimeout(() => this.map.delete(key), this.time); + setTimeout(() => this.map.delete(key), time); } get(key) {