Merge pull request #264 from bforbiggy/patch-1
Group ownership not required for member adding
This commit is contained in:
commit
e4567e9caf
@ -133,15 +133,11 @@ class PartialGroupDMChannel extends Channel {
|
|||||||
* @returns {Promise<PartialGroupDMChannel>}
|
* @returns {Promise<PartialGroupDMChannel>}
|
||||||
*/
|
*/
|
||||||
async addMember(user) {
|
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);
|
user = this.client.users.resolveId(user);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
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'));
|
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();
|
await this.client.api.channels[this.id].recipients[user].put();
|
||||||
this.recipients.set(user, this.client.users.cache.get(user));
|
this.recipients.set(user, this.client.users.cache.get(user));
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
Reference in New Issue
Block a user