Skip to content

Commit

Permalink
add handlers (totally didn't forget) and use "on_" prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
siku2 committed Jul 23, 2019
1 parent dc2158f commit 72f1347
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions component.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (c *Component) Open() error {
return fmt.Errorf("connection to discord failed: %s", err)
}

c.addHandlers()
return c.registerProcedures()
}

Expand All @@ -113,11 +114,11 @@ func (c *Component) Done() <-chan struct{} {

func (c *Component) addHandlers() {
c.discordSess.AddHandler(func(s *discordgo.Session, u *discordgo.VoiceStateUpdate) {
_ = c.wampClient.Publish("com.discord.voice_state_update", nil, wamp.List{u}, nil)
_ = c.wampClient.Publish("com.discord.on_voice_state_update", nil, wamp.List{u}, nil)
})

c.discordSess.AddHandler(func(s *discordgo.Session, u *discordgo.VoiceServerUpdate) {
_ = c.wampClient.Publish("com.discord.voice_server_update", nil, wamp.List{u}, nil)
_ = c.wampClient.Publish("com.discord.on_voice_server_update", nil, wamp.List{u}, nil)
})
}

Expand Down Expand Up @@ -146,6 +147,7 @@ func (c *Component) updateVoiceState(ctx context.Context, args wamp.List, kwargs
deaf, _ := wamp.AsBool(kwargs["deaf"])

err := c.discordSess.ChannelVoiceJoinManual(gID, cID, mute, deaf)

if err != nil {
return resultFromErrorURI(discordErrURI, err.Error())
}
Expand Down

0 comments on commit 72f1347

Please sign in to comment.