feat: allows to create a group without user
This commit is contained in:
@@ -118,16 +118,17 @@ class ChannelManager extends CachedManager {
|
||||
|
||||
/**
|
||||
* Create Group DM
|
||||
* @param {UserResolvable[]} recipients Array of recipients
|
||||
* @param {UserResolvable[]} [recipients=[]] Array of recipients
|
||||
* @returns {Promise<GroupDMChannel>} Channel
|
||||
* @example
|
||||
* client.channels.createGroupDM();
|
||||
*/
|
||||
async createGroupDM(recipients) {
|
||||
// Check
|
||||
async createGroupDM(recipients = []) {
|
||||
if (!Array.isArray(recipients)) throw new Error(`Expected an array of recipients (got ${typeof recipients})`);
|
||||
recipients = recipients
|
||||
.map(r => this.client.users.resolveId(r))
|
||||
.filter(r => r && this.client.relationships.cache.get(r) == RelationshipTypes.FRIEND);
|
||||
if (recipients.length <= 0 || recipients.length > 9) throw new Error('Invalid Users length (1 - 9)');
|
||||
if (recipients.length > 9) throw new Error('Invalid Users length (max=9)');
|
||||
const data = await this.client.api.users['@me'].channels.post({
|
||||
data: { recipients },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user