mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Fixed typing and added createChannel
This commit is contained in:
@@ -251,6 +251,8 @@ var Client = (function (_EventEmitter) {
|
||||
});
|
||||
};
|
||||
|
||||
// def leaveServer
|
||||
|
||||
Client.prototype.leaveServer = function leaveServer(server) {
|
||||
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err) {} : arguments[1];
|
||||
|
||||
@@ -265,6 +267,26 @@ var Client = (function (_EventEmitter) {
|
||||
});
|
||||
};
|
||||
|
||||
// def createChannel
|
||||
|
||||
Client.prototype.createChannel = function createChannel(server, name) {
|
||||
var type = arguments.length <= 2 || arguments[2] === undefined ? "text" : arguments[2];
|
||||
var callback = arguments.length <= 3 || arguments[3] === undefined ? function (err, channel) {} : arguments[3];
|
||||
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (typeof type === "function") {
|
||||
// options is the callback
|
||||
callback = type;
|
||||
}
|
||||
self.internal.createChannel(server, name, type).then(function (channel) {
|
||||
callback(channel);resolve(channel);
|
||||
})["catch"](function (e) {
|
||||
callback(e);reject(e);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return Client;
|
||||
})(EventEmitter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user