Change KeyValue time

This commit is contained in:
Frostbide
2025-06-25 11:43:53 -07:00
parent 7e8ae0a04e
commit 77c5fc4e95
2 changed files with 12 additions and 9 deletions

View File

@@ -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;
},

View File

@@ -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) {