Files
discord.js/src/Structures/Webhook.js
Jacob c00d209014 add webhooks v8 (#759)
* add webhook structure and getChannelWebhooks as well as getServerWebhooks

* add sendMessage

* add the ability to edit create and delete hooks

* remove server wide cache and add getter.
2016-10-01 11:53:14 +01:00

40 lines
755 B
JavaScript

"use strict";
import {Endpoints} from "../Constants";
/* example data
{
id: '164585980739846145'
name: 'wlfSS',
roles: [ '135829612780322816' ],
require_colons: false,
managed: true,
}
*/
export default class Webhook {
constructor(data, server, channel, user) {
this.server = server;
this.channel = channel;
this.id = data.id;
this.user = user || data.user;
this.name = data.name;
this.avatar = data.avatar;
this.token = data.token
}
get getURL() {
return `https://canary.discordapp.com/api/webhooks/${this.channel.id}/${this.token.id}`;
}
toObject() {
let keys = ['id', 'name', 'avatar', 'token'],
obj = {};
for (let k of keys) {
obj[k] = this[k];
}
return obj;
}
}