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.
This commit is contained in:
Jacob
2016-10-01 06:53:14 -04:00
committed by Amish Shah
parent d22ca969db
commit c00d209014
15 changed files with 548 additions and 45 deletions

39
src/Structures/Webhook.js Normal file
View File

@@ -0,0 +1,39 @@
"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;
}
}