feat: allows to create a group without user

This commit is contained in:
Elysia
2024-07-28 16:39:16 +07:00
parent 78977df08b
commit 772739f980
2 changed files with 6 additions and 5 deletions

View File

@@ -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 },
});