-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Voice Channel Effect Send (#10318)
* feat: Voice Channel Send Effects (#9288) * feat: add soundboard fields * chore: address TODO * docs: volume is a closed interval * types: use `GatewayVoiceChannelEffectSendDispatchData` * refactor: prefer getting from cache * fix: correctly access cache Co-authored-by: Danial Raza <[email protected]> --------- Co-authored-by: Danial Raza <[email protected]>
- Loading branch information
1 parent
e2df0e0
commit 6775175
Showing
7 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/discord.js/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const VoiceChannelEffect = require('../../../structures/VoiceChannelEffect'); | ||
const Events = require('../../../util/Events'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
if (!guild) return; | ||
|
||
/** | ||
* Emmited when someone sends an effect, such as an emoji reaction, in a voice channel the client is connected to. | ||
* @event Client#voiceChannelEffectSend | ||
* @param {VoiceChannelEffect} voiceChannelEffect The sent voice channel effect | ||
*/ | ||
client.emit(Events.VoiceChannelEffectSend, new VoiceChannelEffect(data, guild)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict'; | ||
|
||
const { Emoji } = require('./Emoji'); | ||
|
||
/** | ||
* Represents an effect used in a {@link VoiceChannel}. | ||
*/ | ||
class VoiceChannelEffect { | ||
constructor(data, guild) { | ||
/** | ||
* The guild where the effect was sent from. | ||
* @type {Guild} | ||
*/ | ||
this.guild = guild; | ||
|
||
/** | ||
* The id of the channel the effect was sent in. | ||
* @type {Snowflake} | ||
*/ | ||
this.channelId = data.channel_id; | ||
|
||
/** | ||
* The id of the user that sent the effect. | ||
* @type {Snowflake} | ||
*/ | ||
this.userId = data.user_id; | ||
|
||
/** | ||
* The emoji of the effect. | ||
* @type {?Emoji} | ||
*/ | ||
this.emoji = data.emoji ? new Emoji(guild.client, data.emoji) : null; | ||
|
||
/** | ||
* The animation type of the effect. | ||
* @type {?VoiceChannelEffectSendAnimationType} | ||
*/ | ||
this.animationType = data.animation_type ?? null; | ||
|
||
/** | ||
* The animation id of the effect. | ||
* @type {?number} | ||
*/ | ||
this.animationId = data.animation_id ?? null; | ||
|
||
/** | ||
* The id of the soundboard sound for soundboard effects. | ||
* @type {?(Snowflake|number)} | ||
*/ | ||
this.soundId = data.sound_id ?? null; | ||
|
||
/** | ||
* The volume of the soundboard sound [0-1] for soundboard effects. | ||
* @type {?number} | ||
*/ | ||
this.soundVolume = data.sound_volume ?? null; | ||
} | ||
|
||
/** | ||
* The channel the effect was sent in. | ||
* @type {?VoiceChannel} | ||
* @readonly | ||
*/ | ||
get channel() { | ||
return this.guild.channels.cache.get(this.channelId) ?? null; | ||
} | ||
} | ||
|
||
module.exports = VoiceChannelEffect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters