buddy

node MVC discord bot
Log | Files | Refs | README

CHANNEL_PINS_UPDATE.js (894B)


      1 'use strict';
      2 
      3 const { Events } = require('../../../util/Constants');
      4 
      5 module.exports = (client, { d: data }) => {
      6   const channel = client.channels.cache.get(data.channel_id);
      7   const time = new Date(data.last_pin_timestamp);
      8 
      9   if (channel && !Number.isNaN(time.getTime())) {
     10     // Discord sends null for last_pin_timestamp if the last pinned message was removed
     11     channel.lastPinTimestamp = time.getTime() || null;
     12 
     13     /**
     14      * Emitted whenever the pins of a channel are updated. Due to the nature of the WebSocket event,
     15      * not much information can be provided easily here - you need to manually check the pins yourself.
     16      * @event Client#channelPinsUpdate
     17      * @param {DMChannel|TextChannel} channel The channel that the pins update occurred in
     18      * @param {Date} time The time of the pins update
     19      */
     20     client.emit(Events.CHANNEL_PINS_UPDATE, channel, time);
     21   }
     22 };