UNPKG

hennus-api

Version:

Esta es una libreria para el bot Hennus

52 lines (51 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MessagesManager = void 0; const base_1 = require("./base"); class MessagesManager extends base_1.cacheManager { constructor(client) { super(client); this.search = false; } ; async fetch(id, options) { const cache = this.cache.get(id); if (options?.force) { const message = await this.rest.get("channelMessage", options.channelId, id); if (!cache && message) this.cache.set(message.id, message); return message; } ; return cache; } ; async fetchall(channelId) { if (!this.search) this.rest.get("channelMessages", channelId).then((msgs) => { this.search = true; (msgs ?? []).forEach((msg) => this.cache.set(msg.id, msg)); }); return this.cache; } ; async fetchallR(channelId) { return await this.rest.get("channelMessages", channelId); } ; update(message) { if (this.cache.has(message.id)) { const oldMessage = this.cache.get(message.id); if (message.editedTimestamp !== oldMessage?.editedTimestamp) { this.cache.delete(message.id); this.cache.set(message.id, message); } ; } else { this.cache.set(message.id, message); } ; return this; } ; } exports.MessagesManager = MessagesManager; ;