mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Attempting getInvites
This commit is contained in:
@@ -441,6 +441,14 @@ var Client = (function (_EventEmitter) {
|
|||||||
return this.internal.getInvite(invite).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.getInvite(invite).then(dataCallback(callback), errorCallback(callback));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// def getInvites
|
||||||
|
|
||||||
|
Client.prototype.getInvites = function getInvites(channel) {
|
||||||
|
var callback = arguments.length <= 1 || arguments[1] === undefined ? function () /*err, inv*/{} : arguments[1];
|
||||||
|
|
||||||
|
return this.internal.getInvites(channel).then(dataCallback(callback), errorCallback(callback));
|
||||||
|
};
|
||||||
|
|
||||||
// def overwritePermissions
|
// def overwritePermissions
|
||||||
|
|
||||||
Client.prototype.overwritePermissions = function overwritePermissions(channel, role) {
|
Client.prototype.overwritePermissions = function overwritePermissions(channel, role) {
|
||||||
|
|||||||
@@ -962,10 +962,34 @@ var InternalClient = (function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//def getInvites
|
||||||
|
|
||||||
|
InternalClient.prototype.getInvites = function getInvites(channel) {
|
||||||
|
var _this23 = this;
|
||||||
|
|
||||||
|
if (!(channel instanceof _StructuresChannel2["default"])) {
|
||||||
|
var server = this.resolver.resolveServer(channel);
|
||||||
|
if (server) {
|
||||||
|
return this.apiRequest("get", _Constants.Endpoints.SERVER_INVITES(server.id), true).then(function (res) {
|
||||||
|
return res.map(function (data) {
|
||||||
|
return new _StructuresInvite2["default"](data, _this23.channels.get("id", data.channel.id), _this23.client);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
|
return _this23.apiRequest("get", _Constants.Endpoints.CHANNEL_INVITES(channel.id), true).then(function (res) {
|
||||||
|
return res.map(function (data) {
|
||||||
|
return new _StructuresInvite2["default"](data, _this23.channels.get("id", data.channel.id), _this23.client);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
//def overwritePermissions
|
//def overwritePermissions
|
||||||
|
|
||||||
InternalClient.prototype.overwritePermissions = function overwritePermissions(channel, role, updated) {
|
InternalClient.prototype.overwritePermissions = function overwritePermissions(channel, role, updated) {
|
||||||
var _this23 = this;
|
var _this24 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
var user;
|
var user;
|
||||||
@@ -1006,7 +1030,7 @@ var InternalClient = (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _this23.apiRequest("put", _Constants.Endpoints.CHANNEL_PERMISSIONS(channel.id) + "/" + data.id, true, data);
|
return _this24.apiRequest("put", _Constants.Endpoints.CHANNEL_PERMISSIONS(channel.id) + "/" + data.id, true, data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1042,49 +1066,49 @@ var InternalClient = (function () {
|
|||||||
//def sendTyping
|
//def sendTyping
|
||||||
|
|
||||||
InternalClient.prototype.sendTyping = function sendTyping(channel) {
|
InternalClient.prototype.sendTyping = function sendTyping(channel) {
|
||||||
var _this24 = this;
|
var _this25 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
return _this24.apiRequest("post", _Constants.Endpoints.CHANNEL(channel.id) + "/typing", true);
|
return _this25.apiRequest("post", _Constants.Endpoints.CHANNEL(channel.id) + "/typing", true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//def startTyping
|
//def startTyping
|
||||||
|
|
||||||
InternalClient.prototype.startTyping = function startTyping(channel) {
|
InternalClient.prototype.startTyping = function startTyping(channel) {
|
||||||
var _this25 = this;
|
var _this26 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
|
|
||||||
if (_this25.intervals.typing[channel.id]) {
|
if (_this26.intervals.typing[channel.id]) {
|
||||||
// typing interval already exists, leave it alone
|
// typing interval already exists, leave it alone
|
||||||
throw new Error("Already typing in that channel");
|
throw new Error("Already typing in that channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
_this25.intervals.typing[channel.id] = setInterval(function () {
|
_this26.intervals.typing[channel.id] = setInterval(function () {
|
||||||
return _this25.sendTyping(channel)["catch"](function (error) {
|
return _this26.sendTyping(channel)["catch"](function (error) {
|
||||||
return _this25.emit("error", error);
|
return _this26.emit("error", error);
|
||||||
});
|
});
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
|
||||||
return _this25.sendTyping(channel);
|
return _this26.sendTyping(channel);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//def stopTyping
|
//def stopTyping
|
||||||
|
|
||||||
InternalClient.prototype.stopTyping = function stopTyping(channel) {
|
InternalClient.prototype.stopTyping = function stopTyping(channel) {
|
||||||
var _this26 = this;
|
var _this27 = this;
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||||
|
|
||||||
if (!_this26.intervals.typing[channel.id]) {
|
if (!_this27.intervals.typing[channel.id]) {
|
||||||
// typing interval doesn"t exist
|
// typing interval doesn"t exist
|
||||||
throw new Error("Not typing in that channel");
|
throw new Error("Not typing in that channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInterval(_this26.intervals.typing[channel.id]);
|
clearInterval(_this27.intervals.typing[channel.id]);
|
||||||
_this26.intervals.typing[channel.id] = false;
|
_this27.intervals.typing[channel.id] = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1115,12 +1139,12 @@ var InternalClient = (function () {
|
|||||||
//def setChannelTopic
|
//def setChannelTopic
|
||||||
|
|
||||||
InternalClient.prototype.setChannelTopic = function setChannelTopic(chann) {
|
InternalClient.prototype.setChannelTopic = function setChannelTopic(chann) {
|
||||||
var _this27 = this;
|
var _this28 = this;
|
||||||
|
|
||||||
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this27.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this28.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: topic
|
topic: topic
|
||||||
@@ -1133,12 +1157,12 @@ var InternalClient = (function () {
|
|||||||
//def setChannelName
|
//def setChannelName
|
||||||
|
|
||||||
InternalClient.prototype.setChannelName = function setChannelName(chann) {
|
InternalClient.prototype.setChannelName = function setChannelName(chann) {
|
||||||
var _this28 = this;
|
var _this29 = this;
|
||||||
|
|
||||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this28.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this29.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: name,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: channel.topic
|
topic: channel.topic
|
||||||
@@ -1151,13 +1175,13 @@ var InternalClient = (function () {
|
|||||||
//def setChannelNameAndTopic
|
//def setChannelNameAndTopic
|
||||||
|
|
||||||
InternalClient.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(chann) {
|
InternalClient.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(chann) {
|
||||||
var _this29 = this;
|
var _this30 = this;
|
||||||
|
|
||||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
||||||
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this29.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this30.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: name,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: topic
|
topic: topic
|
||||||
@@ -1171,12 +1195,12 @@ var InternalClient = (function () {
|
|||||||
//def setTopic
|
//def setTopic
|
||||||
|
|
||||||
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann) {
|
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann) {
|
||||||
var _this30 = this;
|
var _this31 = this;
|
||||||
|
|
||||||
var position = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
var position = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||||
return _this30.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
return _this31.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
position: position,
|
position: position,
|
||||||
topic: channel.topic
|
topic: channel.topic
|
||||||
@@ -1388,7 +1412,7 @@ var InternalClient = (function () {
|
|||||||
// server exists
|
// server exists
|
||||||
data.members = data.members || [];
|
data.members = data.members || [];
|
||||||
data.channels = data.channels || [];
|
data.channels = data.channels || [];
|
||||||
var newserver = new _StructuresServer2["default"](data, self);
|
var newserver = new _StructuresServer2["default"](data, client);
|
||||||
newserver.members = server.members;
|
newserver.members = server.members;
|
||||||
newserver.memberMap = server.memberMap;
|
newserver.memberMap = server.memberMap;
|
||||||
newserver.channels = server.channels;
|
newserver.channels = server.channels;
|
||||||
@@ -1401,7 +1425,7 @@ var InternalClient = (function () {
|
|||||||
}
|
}
|
||||||
} else if (!server) {
|
} else if (!server) {
|
||||||
client.emit("warn", "server was updated but it was not in the cache");
|
client.emit("warn", "server was updated but it was not in the cache");
|
||||||
self.servers.add(new _StructuresServer2["default"](data, self));
|
self.servers.add(new _StructuresServer2["default"](data, client));
|
||||||
client.emit("serverCreated", server);
|
client.emit("serverCreated", server);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -365,6 +365,12 @@ export default class Client extends EventEmitter {
|
|||||||
.then(dataCallback(callback), errorCallback(callback));
|
.then(dataCallback(callback), errorCallback(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// def getInvites
|
||||||
|
getInvites(channel, callback = (/*err, inv*/) => { }) {
|
||||||
|
return this.internal.getInvites(channel)
|
||||||
|
.then(dataCallback(callback), errorCallback(callback));
|
||||||
|
}
|
||||||
|
|
||||||
// def overwritePermissions
|
// def overwritePermissions
|
||||||
overwritePermissions(channel, role, options = {}, callback = (/*err, {}*/) => { }) {
|
overwritePermissions(channel, role, options = {}, callback = (/*err, {}*/) => { }) {
|
||||||
return this.internal.overwritePermissions(channel, role, options)
|
return this.internal.overwritePermissions(channel, role, options)
|
||||||
|
|||||||
@@ -807,6 +807,26 @@ export default class InternalClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//def getInvites
|
||||||
|
getInvites(channel) {
|
||||||
|
if (!(channel instanceof Channel)) {
|
||||||
|
var server = this.resolver.resolveServer(channel);
|
||||||
|
if (server) {
|
||||||
|
return this.apiRequest("get", Endpoints.SERVER_INVITES(server.id), true)
|
||||||
|
.then(res => {
|
||||||
|
return res.map(data => new Invite(data, this.channels.get("id", data.channel.id), this.client));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.resolver.resolveChannel(channel)
|
||||||
|
.then(channel => {
|
||||||
|
return this.apiRequest("get", Endpoints.CHANNEL_INVITES(channel.id), true)
|
||||||
|
.then(res => {
|
||||||
|
return res.map(data => new Invite(data, this.channels.get("id", data.channel.id), this.client));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//def overwritePermissions
|
//def overwritePermissions
|
||||||
overwritePermissions(channel, role, updated) {
|
overwritePermissions(channel, role, updated) {
|
||||||
return this.resolver.resolveChannel(channel)
|
return this.resolver.resolveChannel(channel)
|
||||||
@@ -1194,7 +1214,7 @@ export default class InternalClient {
|
|||||||
// server exists
|
// server exists
|
||||||
data.members = data.members || [];
|
data.members = data.members || [];
|
||||||
data.channels = data.channels || [];
|
data.channels = data.channels || [];
|
||||||
var newserver = new Server(data, self);
|
var newserver = new Server(data, client);
|
||||||
newserver.members = server.members;
|
newserver.members = server.members;
|
||||||
newserver.memberMap = server.memberMap;
|
newserver.memberMap = server.memberMap;
|
||||||
newserver.channels = server.channels;
|
newserver.channels = server.channels;
|
||||||
@@ -1207,7 +1227,7 @@ export default class InternalClient {
|
|||||||
}
|
}
|
||||||
} else if (!server) {
|
} else if (!server) {
|
||||||
client.emit("warn", "server was updated but it was not in the cache");
|
client.emit("warn", "server was updated but it was not in the cache");
|
||||||
self.servers.add(new Server(data, self));
|
self.servers.add(new Server(data, client));
|
||||||
client.emit("serverCreated", server);
|
client.emit("serverCreated", server);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user