update
This commit is contained in:
@@ -5,6 +5,7 @@ const { Channel } = require('./Channel');
|
||||
const Invite = require('./Invite');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const MessageManager = require('../managers/MessageManager');
|
||||
const { Status, Opcodes } = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
|
||||
/**
|
||||
@@ -291,6 +292,79 @@ class GroupDMChannel extends Channel {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring the user's phone / PC (call)
|
||||
* @param {UserResolvable[]} [recipients] Array of recipients
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
ring(recipients) {
|
||||
if (!recipients || !Array.isArray(recipients) || recipients.length == 0) recipients = null;
|
||||
recipients = recipients.map(r => this.client.users.resolveId(r)).filter(r => r && this.recipients.get(r));
|
||||
return this.client.api.channels(this.id).call.ring.post({
|
||||
data: {
|
||||
recipients,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync VoiceState of this Group DMChannel.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
sync() {
|
||||
this.client.ws.broadcast({
|
||||
op: Opcodes.DM_UPDATE,
|
||||
d: {
|
||||
channel_id: this.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The user in this voice-based channel
|
||||
* @type {Collection<Snowflake, User>}
|
||||
* @readonly
|
||||
*/
|
||||
get voiceUsers() {
|
||||
const coll = new Collection();
|
||||
for (const state of this.client.voiceStates.cache.values()) {
|
||||
if (state.channelId === this.id && state.user) {
|
||||
coll.set(state.id, state.user);
|
||||
}
|
||||
}
|
||||
return coll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current shard
|
||||
* @type {WebSocketShard}
|
||||
* @readonly
|
||||
*/
|
||||
get shard() {
|
||||
return this.client.ws.shards.first();
|
||||
}
|
||||
|
||||
/**
|
||||
* The voice state adapter for this client that can be used with @discordjs/voice to play audio in DM / Group DM channels.
|
||||
* @type {?Function}
|
||||
* @readonly
|
||||
*/
|
||||
get voiceAdapterCreator() {
|
||||
return methods => {
|
||||
this.client.voice.adapters.set(this.id, methods);
|
||||
return {
|
||||
sendPayload: data => {
|
||||
if (this.shard.status !== Status.READY) return false;
|
||||
this.shard.send(data);
|
||||
return true;
|
||||
},
|
||||
destroy: () => {
|
||||
this.client.voice.adapters.delete(this.id);
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||
/* eslint-disable no-empty-function */
|
||||
get lastMessage() {}
|
||||
|
||||
Reference in New Issue
Block a user