Merge pull request #264 from bforbiggy/patch-1

Group ownership not required for member adding
This commit is contained in:
Cinnamon 2022-08-19 17:36:53 +07:00 committed by GitHub
commit e4567e9caf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,15 +133,11 @@ class PartialGroupDMChannel extends Channel {
* @returns {Promise<PartialGroupDMChannel>}
*/
async addMember(user) {
if (this.ownerId !== this.client.user.id) {
return Promise.reject(new Error('NOT_OWNER_GROUP_DM_CHANNEL'));
}
user = this.client.users.resolveId(user);
if (!user) {
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'));
//
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.set(user, this.client.users.cache.get(user));
return this;