Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle voice channel effect send events #1547

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ declare namespace Eris {
// Voice
type ConverterCommand = "./ffmpeg" | "./avconv" | "ffmpeg" | "avconv";
type StageInstancePrivacyLevel = Constants["StageInstancePrivacyLevel"][keyof Constants["StageInstancePrivacyLevel"]];
type VoiceChannelEffectAnimationType = Constants["VoiceChannelEffectAnimationTypes"][keyof Constants["VoiceChannelEffectAnimationTypes"]];

// Webhook
type WebhookPayloadEdit = Pick<WebhookPayload, "attachments" | "content" | "embed" | "embeds" | "file" | "allowedMentions" | "components">;
Expand Down Expand Up @@ -937,6 +938,7 @@ declare namespace Eris {
unavailableGuildCreate: [guild: UnavailableGuild];
unknown: [packet: RawPacket, id?: number];
userUpdate: [user: User, oldUser: PartialUser | null];
voiceChannelEffectSend: [effect: VoiceChannelEffect];
voiceChannelJoin: [member: Member, channel: AnyVoiceChannel];
voiceChannelLeave: [member: Member, channel: AnyVoiceChannel];
voiceChannelStatusUpdate: [channel: AnyVoiceChannel, oldChannel: VoiceStatus];
Expand Down Expand Up @@ -1828,6 +1830,16 @@ declare namespace Eris {
id: string;
voiceState: OldVoiceState;
}
interface VoiceChannelEffect {
animationID?: number;
animationType?: VoiceChannelEffectAnimationType | null;
channel: PossiblyUncachedSpeakableChannel;
emoji?: PartialEmoji | null;
guild: PossiblyUncachedGuild;
soundID?: string | number;
soundVolume?: number;
user: User | Uncached;
}
interface VoiceConnectData {
channel_id: string;
endpoint: string;
Expand Down
4 changes: 4 additions & 0 deletions lib/Constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ export default interface Constants {
AUTO: 1;
FULL: 2;
};
VoiceChannelEffectAnimationTypes: {
PREMIUM: 0;
BASIC: 1;
};
VoiceOPCodes: {
IDENTIFY: 0;
SELECT_PROTOCOL: 1;
Expand Down
5 changes: 5 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@ module.exports.VideoQualityModes = {
FULL: 2,
};

module.exports.VoiceChannelEffectAnimationTypes = {
PREMIUM: 0,
BASIC: 1,
};

module.exports.VoiceOPCodes = {
IDENTIFY: 0,
SELECT_PROTOCOL: 1,
Expand Down
29 changes: 29 additions & 0 deletions lib/gateway/Shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,35 @@ class Shard extends EventEmitter {
this.emit("voiceChannelStatusUpdate", channel, oldChannel);
break;
}
case "VOICE_CHANNEL_EFFECT_SEND": {
const channel = this.client.getChannel(packet.d.channel_id) || { id: packet.d.channel_id };
const guild = this.client.guilds.get(packet.d.guild_id) || { id: packet.d.guild_id };
const user = this.client.users.get(packet.d.user_id) || { id: packet.d.user_id };
/**
* Fired when a user sends a voice channel effect
* @event Client#voiceChannelEffectSend
* @prop {Object} effect The effect that was sent
* @prop {Number?} effect.animationID The animation ID
* @prop {Number?} effect.animationType The animation type
* @prop {VoiceChannel | StageChannel | Object} effect.channel The voice channel the effect was sent in. If the channel is not cached, this will be an object with an `id` key. No other property is guaranteed
* @prop {Object?} effect.emoji The emoji sent
* @prop {Guild | Object} effect.guild The guild the effect was sent in. If the guild is not cached, this will be an object with an `id` key. No other property is guaranteed
* @prop {(String | Number)?} effect.soundID The sound ID
* @prop {Number?} effect.soundVolume The volume of the sound (a number between 0 and 1)
* @prop {User | Object} effect.user The user that sent the effect. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed
*/
this.emit("voiceChannelEffectSend", {
channel: channel,
guild: guild,
user: user,
emoji: packet.d.emoji,
animationType: packet.d.animation_type,
animationID: packet.d.animation_id,
soundID: packet.d.sound_id,
soundVolume: packet.d.sound_volume,
});
break;
}
case "TYPING_START": {
let member = null;
const guild = this.client.guilds.get(packet.d.guild_id);
Expand Down