Update PartialGroupDMChannel.js
This commit is contained in:
parent
c75a5e3b04
commit
1116a71f7b
@ -154,13 +154,14 @@ class PartialGroupDMChannel extends Channel {
|
|||||||
* @returns {Promise<PartialGroupDMChannel>}
|
* @returns {Promise<PartialGroupDMChannel>}
|
||||||
*/
|
*/
|
||||||
async addMember(user) {
|
async addMember(user) {
|
||||||
user = this.client.users.resolveId(user);
|
const userId = this.client.users.resolveId(user);
|
||||||
if (!user) {
|
user = this.client.users.resolve(userId);
|
||||||
|
if (!userId) {
|
||||||
return Promise.reject(new TypeError('User is not a User or User ID'));
|
return Promise.reject(new TypeError('User is not a User or User ID'));
|
||||||
}
|
}
|
||||||
if (this.recipients.get(user)) return Promise.reject(new Error('USER_ALREADY_IN_GROUP_DM_CHANNEL')); // Fails sometimes if member leaves recently (ex. user leave msg's channel used for adding)
|
if (this.recipients.get(userId)) return Promise.reject(new Error('USER_ALREADY_IN_GROUP_DM_CHANNEL')); // Fails sometimes if member leaves recently (ex. user leave msg's channel used for adding)
|
||||||
await this.client.api.channels[this.id].recipients[user].put();
|
await this.client.api.channels[this.id].recipients[userId].put();
|
||||||
this._recipients = this._recipients.filter(r => r.id !== user);
|
this._recipients.push(user);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user