UNPKG

guilded.ts

Version:

A powerful NPM module that allows you to easily interact with the Guilded API.

41 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleted = exports.updated = exports.created = void 0; const Doc_1 = require("../../structures/Doc"); /** * Handle the DocCreated event. * @param client The client the Websocket belongs to. * @param data The data of the event. */ async function created(client, data) { const channel = (await client.channels.fetch(data.doc.channelId)); const doc = new Doc_1.Doc(channel, data.doc); client.emit('docCreate', doc); } exports.created = created; /** * Handle the DocUpdated event. * @param client The client the Websocket belongs to. * @param data The data of the event. */ async function updated(client, data) { const channel = (await client.channels.fetch(data.doc.channelId)); const oldDoc = channel.docs.cache.get(data.doc.id); const newDoc = new Doc_1.Doc(channel, data.doc); client.emit('docEdit', newDoc, oldDoc); } exports.updated = updated; /** * Handle the DocDeleted event. * @param client The client the Websocket belongs to. * @param data The data of the event. */ async function deleted(client, data) { const channel = (await client.channels.fetch(data.doc.channelId)); const doc = new Doc_1.Doc(channel, data.doc); if (client.options.disposeCachedDocs ?? true) channel.docs.cache.delete(doc.id); client.emit('docDelete', doc); } exports.deleted = deleted; //# sourceMappingURL=doc.js.map