mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
Attempt to fix startPM
This commit is contained in:
@@ -576,7 +576,7 @@ var InternalClient = (function () {
|
|||||||
return Promise.reject(new Error("Unable to resolve resUser to a User"));
|
return Promise.reject(new Error("Unable to resolve resUser to a User"));
|
||||||
}
|
}
|
||||||
// start the PM
|
// start the PM
|
||||||
return this.apiRequest("post", _Constants.Endpoints.USER_CHANNELS(user.id), true, {
|
return this.apiRequest("post", _Constants.Endpoints.USER_CHANNELS(this.user.id), true, {
|
||||||
recipient_id: user.id
|
recipient_id: user.id
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return _this13.private_channels.add(new _StructuresPMChannel2["default"](res, _this13.client));
|
return _this13.private_channels.add(new _StructuresPMChannel2["default"](res, _this13.client));
|
||||||
|
|||||||
@@ -290,7 +290,6 @@ var Resolver = (function () {
|
|||||||
}
|
}
|
||||||
if (resource instanceof _StructuresUser2["default"]) {
|
if (resource instanceof _StructuresUser2["default"]) {
|
||||||
// see if a PM exists
|
// see if a PM exists
|
||||||
var chatFound = false;
|
|
||||||
for (var _iterator3 = this.internal.private_channels, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
|
for (var _iterator3 = this.internal.private_channels, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
|
||||||
var _ref3;
|
var _ref3;
|
||||||
|
|
||||||
@@ -306,15 +305,10 @@ var Resolver = (function () {
|
|||||||
var pmchat = _ref3;
|
var pmchat = _ref3;
|
||||||
|
|
||||||
if (pmchat.recipient.equals(resource)) {
|
if (pmchat.recipient.equals(resource)) {
|
||||||
chatFound = pmchat;
|
return Promise.resolve(pmchat);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatFound) {
|
|
||||||
// a PM already exists!
|
|
||||||
return Promise.resolve(chatFound);
|
|
||||||
}
|
|
||||||
// PM does not exist :\
|
// PM does not exist :\
|
||||||
return this.internal.startPM(resource);
|
return this.internal.startPM(resource);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ export default class InternalClient {
|
|||||||
return Promise.reject(new Error("Unable to resolve resUser to a User"));
|
return Promise.reject(new Error("Unable to resolve resUser to a User"));
|
||||||
}
|
}
|
||||||
// start the PM
|
// start the PM
|
||||||
return this.apiRequest("post", Endpoints.USER_CHANNELS(user.id), true, {
|
return this.apiRequest("post", Endpoints.USER_CHANNELS(this.user.id), true, {
|
||||||
recipient_id: user.id
|
recipient_id: user.id
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|||||||
@@ -220,18 +220,12 @@ export default class Resolver {
|
|||||||
}
|
}
|
||||||
if (resource instanceof User) {
|
if (resource instanceof User) {
|
||||||
// see if a PM exists
|
// see if a PM exists
|
||||||
var chatFound = false;
|
|
||||||
for (var pmchat of this.internal.private_channels) {
|
for (var pmchat of this.internal.private_channels) {
|
||||||
if (pmchat.recipient.equals(resource)) {
|
if (pmchat.recipient.equals(resource)) {
|
||||||
chatFound = pmchat;
|
return Promise.resolve(pmchat);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatFound) {
|
|
||||||
// a PM already exists!
|
|
||||||
return Promise.resolve(chatFound);
|
|
||||||
}
|
|
||||||
// PM does not exist :\
|
// PM does not exist :\
|
||||||
return this.internal.startPM(resource);
|
return this.internal.startPM(resource);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user