mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
feat(Voice): implement support for @discordjs/voice (#5402)
This commit is contained in:
@@ -25,6 +25,7 @@ const {
|
||||
VerificationLevels,
|
||||
ExplicitContentFilterLevels,
|
||||
NSFWLevels,
|
||||
Status,
|
||||
} = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||
@@ -1328,6 +1329,35 @@ class Guild extends BaseGuild {
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* The voice state adapter for this guild that can be used with @discordjs/voice to play audio in voice
|
||||
* and stage channels.
|
||||
* @type {Function}
|
||||
* @readonly
|
||||
* @example
|
||||
* const { joinVoiceChannel } = require('@discordjs/voice');
|
||||
* const voiceConnection = joinVoiceChannel({
|
||||
* channelId: channel.id,
|
||||
* guildId: channel.guild.id,
|
||||
* adapterCreator: channel.guild.voiceAdapterCreator,
|
||||
* });
|
||||
*/
|
||||
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);
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a collection of this guild's roles, sorted by their position and IDs.
|
||||
* @returns {Collection<Snowflake, Role>}
|
||||
|
||||
Reference in New Issue
Block a user