mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 12:35:53 +00:00
De-stupify RESTMethods.getExistingDM
This commit is contained in:
parent
b0adc881f3
commit
bb0ca11776
1 changed files with 4 additions and 6 deletions
|
|
@ -59,8 +59,7 @@ class RESTMethods {
|
|||
|
||||
if (channel instanceof User || channel instanceof GuildMember) {
|
||||
this.createDM(channel).then(chan => {
|
||||
channel = chan;
|
||||
this._sendMessageRequest(channel, content, file, tts, nonce, resolve, reject);
|
||||
this._sendMessageRequest(chan, content, file, tts, nonce, resolve, reject);
|
||||
})
|
||||
.catch(reject);
|
||||
} else {
|
||||
|
|
@ -150,10 +149,9 @@ class RESTMethods {
|
|||
}
|
||||
|
||||
getExistingDM(recipient) {
|
||||
const dmChannel = Array.from(this.rest.client.channels.values())
|
||||
.filter(channel => channel.recipient)
|
||||
.filter(channel => channel.recipient.id === recipient.id);
|
||||
return dmChannel[0];
|
||||
return this.rest.client.channels.filter(channel =>
|
||||
channel.recipient && channel.recipient.id === recipient.id
|
||||
).first();
|
||||
}
|
||||
|
||||
createDM(recipient) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue