buddy

node MVC discord bot
Log | Files | Refs | README

ChannelCreate.js (641B)


      1 'use strict';
      2 
      3 const Action = require('./Action');
      4 const { Events } = require('../../util/Constants');
      5 
      6 class ChannelCreateAction extends Action {
      7   handle(data) {
      8     const client = this.client;
      9     const existing = client.channels.cache.has(data.id);
     10     const channel = client.channels.add(data);
     11     if (!existing && channel) {
     12       /**
     13        * Emitted whenever a channel is created.
     14        * @event Client#channelCreate
     15        * @param {DMChannel|GuildChannel} channel The channel that was created
     16        */
     17       client.emit(Events.CHANNEL_CREATE, channel);
     18     }
     19     return { channel };
     20   }
     21 }
     22 
     23 module.exports = ChannelCreateAction;