From 1116a71f7b7b57e1fec7aeaecae5f08604caaa74 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sat, 17 Jun 2023 23:19:17 +0700 Subject: [PATCH] Update PartialGroupDMChannel.js --- src/structures/PartialGroupDMChannel.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/structures/PartialGroupDMChannel.js b/src/structures/PartialGroupDMChannel.js index babd470..45bbff2 100644 --- a/src/structures/PartialGroupDMChannel.js +++ b/src/structures/PartialGroupDMChannel.js @@ -154,13 +154,14 @@ class PartialGroupDMChannel extends Channel { * @returns {Promise} */ async addMember(user) { - user = this.client.users.resolveId(user); - if (!user) { + const userId = this.client.users.resolveId(user); + user = this.client.users.resolve(userId); + if (!userId) { 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) - await this.client.api.channels[this.id].recipients[user].put(); - this._recipients = this._recipients.filter(r => r.id !== user); + 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[userId].put(); + this._recipients.push(user); return this; }