mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
Built internal changes
This commit is contained in:
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -1,2 +1,5 @@
|
|||||||
// Place your settings in this file to overwrite default and user settings.
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
{ "editor.wrappingColumn": 0 }
|
{
|
||||||
|
"editor.wrappingColumn": 0,
|
||||||
|
"editor.formatOnType": true
|
||||||
|
}
|
||||||
@@ -142,6 +142,34 @@ var InternalClient = (function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//def joinServer
|
||||||
|
|
||||||
|
InternalClient.prototype.joinServer = function joinServer(invite) {
|
||||||
|
var self = this;
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
invite = self.resolver.resolveInvite(invite);
|
||||||
|
if (invite) {
|
||||||
|
|
||||||
|
request.post(Endpoints.INVITE(invite.id)).set("authorization", self.token).end(function (err, res) {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
// valid server, wait until it is received via ws and cached
|
||||||
|
var inter = setInterval(function () {
|
||||||
|
if (self.servers.get("id", res.body.guild.id)) {
|
||||||
|
clearInterval(inter);
|
||||||
|
resolve(self.servers.get("id", res.body.guild.id));
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
reject(new Error("Not a valid invite"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
//def leaveServer
|
//def leaveServer
|
||||||
|
|
||||||
InternalClient.prototype.leaveServer = function leaveServer(srv) {
|
InternalClient.prototype.leaveServer = function leaveServer(srv) {
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ var User = require("../../Structures/User.js"),
|
|||||||
ServerChannel = require("../../Structures/ServerChannel.js"),
|
ServerChannel = require("../../Structures/ServerChannel.js"),
|
||||||
PMChannel = require("../../Structures/PMChannel.js"),
|
PMChannel = require("../../Structures/PMChannel.js"),
|
||||||
Server = require("../../Structures/Server.js"),
|
Server = require("../../Structures/Server.js"),
|
||||||
Message = require("../../Structures/Message.js");
|
Message = require("../../Structures/Message.js"),
|
||||||
|
Invite = require("../../Structures/Invite.js");
|
||||||
|
|
||||||
var Resolver = (function () {
|
var Resolver = (function () {
|
||||||
function Resolver(internal) {
|
function Resolver(internal) {
|
||||||
@@ -20,6 +21,21 @@ var Resolver = (function () {
|
|||||||
this.internal = internal;
|
this.internal = internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Resolver.prototype.resolveInvite = function resolveInvite(resource) {
|
||||||
|
if (resource instanceof Invite) {
|
||||||
|
return resource;
|
||||||
|
} else if (typeof resource == "string" || resource instanceof String) {
|
||||||
|
|
||||||
|
if (resource.indexOf("http") === 0) {
|
||||||
|
var split = resource.split("/");
|
||||||
|
return split.pop();
|
||||||
|
} else {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
Resolver.prototype.resolveServer = function resolveServer(resource) {
|
Resolver.prototype.resolveServer = function resolveServer(resource) {
|
||||||
if (resource instanceof Server) {
|
if (resource instanceof Server) {
|
||||||
return resource;
|
return resource;
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ var Endpoints = {
|
|||||||
AVATAR: function AVATAR(userID, avatar) {
|
AVATAR: function AVATAR(userID, avatar) {
|
||||||
return API + "/users/" + userID + "/avatars/" + avatar + ".jpg";
|
return API + "/users/" + userID + "/avatars/" + avatar + ".jpg";
|
||||||
},
|
},
|
||||||
|
INVITE: function INVITE(id) {
|
||||||
|
return API + "/invite/" + id;
|
||||||
|
},
|
||||||
|
|
||||||
// servers
|
// servers
|
||||||
SERVERS: API + "/guilds",
|
SERVERS: API + "/guilds",
|
||||||
|
|||||||
@@ -6,27 +6,27 @@ var Server = require("./Server.js");
|
|||||||
var ServerChannel = require("./ServerChannel.js");
|
var ServerChannel = require("./ServerChannel.js");
|
||||||
|
|
||||||
var Invite = (function () {
|
var Invite = (function () {
|
||||||
function Invite(data, chan, client) {
|
function Invite(data, chan, client) {
|
||||||
_classCallCheck(this, Invite);
|
_classCallCheck(this, Invite);
|
||||||
|
|
||||||
this.maxAge = data.max_age;
|
this.maxAge = data.max_age;
|
||||||
this.code = data.code;
|
this.code = data.code;
|
||||||
this.server = chan.server;
|
this.server = chan.server;
|
||||||
this.channel = chan;
|
this.channel = chan;
|
||||||
this.revoked = data.revoked;
|
this.revoked = data.revoked;
|
||||||
this.createdAt = Date.parse(data.created_at);
|
this.createdAt = Date.parse(data.created_at);
|
||||||
this.temporary = data.temporary;
|
this.temporary = data.temporary;
|
||||||
this.uses = data.uses;
|
this.uses = data.uses;
|
||||||
this.maxUses = data.uses;
|
this.maxUses = data.uses;
|
||||||
this.inviter = client.internal.users.get("id", data.inviter.id);
|
this.inviter = client.internal.users.get("id", data.inviter.id);
|
||||||
this.xkcd = data.xkcdpass;
|
this.xkcd = data.xkcdpass;
|
||||||
}
|
}
|
||||||
|
|
||||||
Invite.prototype.toString = function toString() {
|
Invite.prototype.toString = function toString() {
|
||||||
return "https://discord.gg/" + this.code;
|
return "https://discord.gg/" + this.code;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Invite;
|
return Invite;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
module.exports = Invite;
|
module.exports = Invite;
|
||||||
Reference in New Issue
Block a user