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

Add GuildVoiceChannelEffectSend #282

Merged
merged 14 commits into from
Aug 24, 2024
8 changes: 8 additions & 0 deletions discord/soundboard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package discord

type SoundboardEffectAnimationType int

const (
SoundboardEffectAnimationTypePremium SoundboardEffectAnimationType = iota
SoundboardEffectAnimationTypeBasic
)
6 changes: 6 additions & 0 deletions events/guild_voice_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import (
"github.com/disgoorg/disgo/gateway"
)

// GuildVoiceChannelEffectSend indicates that a discord.User sent an effect in a discord.GuildVoiceChannel
type GuildVoiceChannelEffectSend struct {
*GenericEvent
gateway.EventVoiceChannelEffectSend
}

// GenericGuildVoiceState is called upon receiving GuildVoiceJoin , GuildVoiceMove , GuildVoiceLeave
type GenericGuildVoiceState struct {
*GenericEvent
Expand Down
15 changes: 10 additions & 5 deletions events/listener_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ type ListenerAdapter struct {
OnGuildMessageReactionRemoveAll func(event *GuildMessageReactionRemoveAll)

// Guild Voice Events
OnVoiceServerUpdate func(event *VoiceServerUpdate)
OnGuildVoiceStateUpdate func(event *GuildVoiceStateUpdate)
OnGuildVoiceJoin func(event *GuildVoiceJoin)
OnGuildVoiceMove func(event *GuildVoiceMove)
OnGuildVoiceLeave func(event *GuildVoiceLeave)
OnVoiceServerUpdate func(event *VoiceServerUpdate)
OnGuildVoiceChannelEffectSend func(event *GuildVoiceChannelEffectSend)
OnGuildVoiceStateUpdate func(event *GuildVoiceStateUpdate)
OnGuildVoiceJoin func(event *GuildVoiceJoin)
OnGuildVoiceMove func(event *GuildVoiceMove)
OnGuildVoiceLeave func(event *GuildVoiceLeave)

// Guild StageInstance Events
OnStageInstanceCreate func(event *StageInstanceCreate)
Expand Down Expand Up @@ -483,6 +484,10 @@ func (l *ListenerAdapter) OnEvent(event bot.Event) {
if listener := l.OnVoiceServerUpdate; listener != nil {
listener(e)
}
case *GuildVoiceChannelEffectSend:
if listener := l.OnGuildVoiceChannelEffectSend; listener != nil {
listener(e)
}
case *GuildVoiceStateUpdate:
if listener := l.OnGuildVoiceStateUpdate; listener != nil {
listener(e)
Expand Down
1 change: 1 addition & 0 deletions gateway/gateway_event_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const (
EventTypeStageInstanceUpdate EventType = "STAGE_INSTANCE_UPDATE"
EventTypeTypingStart EventType = "TYPING_START"
EventTypeUserUpdate EventType = "USER_UPDATE"
EventTypeVoiceChannelEffectSend EventType = "VOICE_CHANNEL_EFFECT_SEND"
EventTypeVoiceStateUpdate EventType = "VOICE_STATE_UPDATE"
EventTypeVoiceServerUpdate EventType = "VOICE_SERVER_UPDATE"
EventTypeWebhooksUpdate EventType = "WEBHOOKS_UPDATE"
Expand Down
14 changes: 14 additions & 0 deletions gateway/gateway_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,20 @@ type EventUserUpdate struct {
func (EventUserUpdate) messageData() {}
func (EventUserUpdate) eventData() {}

type EventVoiceChannelEffectSend struct {
ChannelID snowflake.ID `json:"channel_id"`
GuildID snowflake.ID `json:"guild_id"`
UserID snowflake.ID `json:"user_id"`
Emoji *discord.Emoji `json:"emoji"`
AnimationType *discord.SoundboardEffectAnimationType `json:"animation_type,omitempty"`
AnimationID *int `json:"animation_id,omitempty"`
SoundID *snowflake.ID `json:"sound_id,omitempty"`
sebm253 marked this conversation as resolved.
Show resolved Hide resolved
SoundVolume *float64 `json:"sound_volume,omitempty"`
}

func (EventVoiceChannelEffectSend) messageData() {}
func (EventVoiceChannelEffectSend) eventData() {}

type EventVoiceStateUpdate struct {
discord.VoiceState
Member discord.Member `json:"member"`
Expand Down
5 changes: 5 additions & 0 deletions gateway/gateway_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ func UnmarshalEventData(data []byte, eventType EventType) (EventData, error) {
err = json.Unmarshal(data, &d)
eventData = d

case EventTypeVoiceChannelEffectSend:
var d EventVoiceChannelEffectSend
err = json.Unmarshal(data, &d)
eventData = d

case EventTypeVoiceStateUpdate:
var d EventVoiceStateUpdate
err = json.Unmarshal(data, &d)
Expand Down
1 change: 1 addition & 0 deletions handlers/all_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ var allEventHandlers = []bot.GatewayEventHandler{
bot.NewGatewayEventHandler(gateway.EventTypeTypingStart, gatewayHandlerTypingStart),
bot.NewGatewayEventHandler(gateway.EventTypeUserUpdate, gatewayHandlerUserUpdate),

bot.NewGatewayEventHandler(gateway.EventTypeVoiceChannelEffectSend, gatewayHandlerVoiceChannelEffectSend),
bot.NewGatewayEventHandler(gateway.EventTypeVoiceStateUpdate, gatewayHandlerVoiceStateUpdate),
bot.NewGatewayEventHandler(gateway.EventTypeVoiceServerUpdate, gatewayHandlerVoiceServerUpdate),

Expand Down
7 changes: 7 additions & 0 deletions handlers/voice_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import (
"github.com/disgoorg/disgo/gateway"
)

func gatewayHandlerVoiceChannelEffectSend(client bot.Client, sequenceNumber int, shardID int, event gateway.EventVoiceChannelEffectSend) {
client.EventManager().DispatchEvent(&events.GuildVoiceChannelEffectSend{
GenericEvent: events.NewGenericEvent(client, sequenceNumber, shardID),
EventVoiceChannelEffectSend: event,
})
}

func gatewayHandlerVoiceStateUpdate(client bot.Client, sequenceNumber int, shardID int, event gateway.EventVoiceStateUpdate) {
member := event.Member

Expand Down
Loading