mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Fix login, clone objects when firing x-Updated events
This commit is contained in:
@@ -434,7 +434,7 @@ var InternalClient = (function () {
|
||||
var tk = this.tokenCacher.getToken(email, password);
|
||||
if (tk) {
|
||||
this.client.emit("debug", "bypassed direct API login, used cached token");
|
||||
return loginWithToken(tk, email, password);
|
||||
return this.loginWithToken(tk, email, password);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1386,7 +1386,7 @@ var InternalClient = (function () {
|
||||
data.mentions = data.mentions || msg.mentions;
|
||||
data.author = data.author || msg.author;
|
||||
var nmsg = new _StructuresMessage2["default"](data, channel, client);
|
||||
client.emit("messageUpdated", nmsg, msg);
|
||||
client.emit("messageUpdated", new _StructuresMessage2["default"](msg, channel, client), nmsg);
|
||||
channel.messages.update(msg, nmsg);
|
||||
}
|
||||
} else {
|
||||
@@ -1449,8 +1449,8 @@ var InternalClient = (function () {
|
||||
// already the same don't do anything
|
||||
client.emit("debug", "received server update but server already updated");
|
||||
} else {
|
||||
client.emit("serverUpdated", new _StructuresServer2["default"](server, client), newserver);
|
||||
self.servers.update(server, newserver);
|
||||
client.emit("serverUpdated", server, newserver);
|
||||
}
|
||||
} else if (!server) {
|
||||
client.emit("warn", "server was updated but it was not in the cache");
|
||||
@@ -1502,22 +1502,22 @@ var InternalClient = (function () {
|
||||
|
||||
if (channel instanceof _StructuresPMChannel2["default"]) {
|
||||
//PM CHANNEL
|
||||
client.emit("channelUpdated", channel, self.private_channels.update(channel, new _StructuresPMChannel2["default"](data, client)));
|
||||
client.emit("channelUpdated", new _StructuresPMChannel2["default"](channel, client), self.private_channels.update(channel, new _StructuresPMChannel2["default"](data, client)));
|
||||
} else {
|
||||
if (channel.server) {
|
||||
if (channel.type === "text") {
|
||||
//TEXT CHANNEL
|
||||
var chan = new _StructuresTextChannel2["default"](data, client, channel.server);
|
||||
chan.messages = channel.messages;
|
||||
client.emit("channelUpdated", channel, chan);
|
||||
channel.server.channels.update(channel, chan);
|
||||
self.channels.update(channel, chan);
|
||||
client.emit("channelUpdated", channel, chan);
|
||||
} else {
|
||||
//VOICE CHANNEL
|
||||
var chan = new _StructuresVoiceChannel2["default"](data, client, channel.server);
|
||||
client.emit("channelUpdated", channel, chan);
|
||||
channel.server.channels.update(channel, chan);
|
||||
self.channels.update(channel, chan);
|
||||
client.emit("channelUpdated", channel, chan);
|
||||
}
|
||||
} else {
|
||||
client.emit("warn", "channel updated but server non-existant");
|
||||
@@ -1555,8 +1555,8 @@ var InternalClient = (function () {
|
||||
var role = server.roles.get("id", data.role.id);
|
||||
if (role) {
|
||||
var newRole = new _StructuresRole2["default"](data.role, server, client);
|
||||
client.emit("serverRoleUpdated", new _StructuresRole2["default"](role, server, client), newRole);
|
||||
server.roles.update(role, newRole);
|
||||
client.emit("serverRoleUpdated", role, newRole);
|
||||
} else {
|
||||
client.emit("warn", "server role updated but role not in cache");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user