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

View File

@@ -1191,6 +1191,63 @@ var Client = (function (_EventEmitter) {
return this.internal.removeFriend(user).then(dataCallback(callback), errorCallback(callback));
};
Client.prototype.getServerWebhooks = function getServerWebhooks(guild) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err, {}*/{} : arguments[1];
return this.internal.getServerWebhooks(guild).then(dataCallback(callback), errorCallback(callback));
};
Client.prototype.getChannelWebhooks = function getChannelWebhooks(channel) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err, {}*/{} : arguments[1];
return this.internal.getChannelWebhooks(channel).then(dataCallback(callback), errorCallback(callback));
};
Client.prototype.sendWebhookMessage = function sendWebhookMessage(webhook, content) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err, {}*/{} : arguments[3];
if (typeof options === "function") {
// options is the callback
callback = options;
options = {};
}
return this.internal.sendWebhookMessage(webhook, content, options).then(dataCallback(callback), errorCallback(callback));
};
Client.prototype.editWebhook = function editWebhook(webhook) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err, {}*/{} : arguments[2];
if (typeof options === "function") {
// options is the callback
callback = options;
options = {};
}
return this.internal.editWebhook(webhook, options).then(dataCallback(callback), errorCallback(callback));
};
Client.prototype.createWebhook = function createWebhook(webhook) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err, {}*/{} : arguments[2];
if (typeof options === "function") {
// options is the callback
callback = options;
options = {};
}
return this.internal.createWebhook(webhook, options).then(dataCallback(callback), errorCallback(callback));
};
Client.prototype.deleteWebhook = function deleteWebhook(webhook) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err, {}*/{} : arguments[1];
return this.internal.createWebhook(webhook).then(dataCallback(callback), errorCallback(callback));
};
// def getOAuthApplication
Client.prototype.getOAuthApplication = function getOAuthApplication(appID) {