buddy

node MVC discord bot
Log | Files | Refs | README

WebhookClient.js (895B)


      1 'use strict';
      2 
      3 const BaseClient = require('./BaseClient');
      4 const Webhook = require('../structures/Webhook');
      5 
      6 /**
      7  * The webhook client.
      8  * @implements {Webhook}
      9  * @extends {BaseClient}
     10  */
     11 class WebhookClient extends BaseClient {
     12   /**
     13    * @param {Snowflake} id ID of the webhook
     14    * @param {string} token Token of the webhook
     15    * @param {ClientOptions} [options] Options for the client
     16    * @example
     17    * // Create a new webhook and send a message
     18    * const hook = new Discord.WebhookClient('1234', 'abcdef');
     19    * hook.send('This will send a message').catch(console.error);
     20    */
     21   constructor(id, token, options) {
     22     super(options);
     23     Object.defineProperty(this, 'client', { value: this });
     24     this.id = id;
     25     Object.defineProperty(this, 'token', { value: token, writable: true, configurable: true });
     26   }
     27 }
     28 
     29 Webhook.applyToClass(WebhookClient);
     30 
     31 module.exports = WebhookClient;