Group DM channel

Feature list: Create, Add member, Remove member, fetchInvite, createInvite, setName, setIcon, send Message, leave .-.
This commit is contained in:
March 7th
2022-04-03 11:53:09 +07:00
parent ed996371b0
commit 54d0e9d272
8 changed files with 561 additions and 307 deletions

View File

@@ -4,6 +4,8 @@ const process = require('node:process');
const CachedManager = require('./CachedManager');
const { Channel } = require('../structures/Channel');
const { Events, ThreadChannelTypes } = require('../util/Constants');
const User = require('../structures/User');
const PartialGroupDMChannel = require('../structures/PartialGroupDMChannel');
let cacheWarningEmitted = false;
@@ -113,8 +115,27 @@ class ChannelManager extends CachedManager {
}
const data = await this.client.api.channels(id).get();
// delete in cache
this._remove(id);
return this._add(data, null, { cache, allowUnknownGuild });
}
// Create Group DM
/**
* Create Group DM
* @param {Array<Discord.User>} recipients Array of recipients
* @returns {PartialGroupDMChannel} Channel
*/
async createGroupDM(recipients) {
// Check
if (!recipients || !Array.isArray(recipients)) throw new Error('No recipients || Invalid Type (Array)');
recipients = recipients.filter(r => r instanceof User && r.id && r.friend);
console.log(recipients);
if (recipients.length < 2 || recipients.length > 9) throw new Error('Invalid Users length (2 - 9)');
const data = await this.client.api.users['@me'].channels.post({
data: { recipients: recipients.map((r) => r.id) },
});
return this._add(data, null, { cache: true, allowUnknownGuild: true });
}
}
module.exports = ChannelManager;

View File

@@ -1 +0,0 @@
// Todo: create, add, remove, update