Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Mar 11, 2023
1 parent a2c315e commit 55eafb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions _examples/discordgo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ func (b *Bot) onVoiceStateUpdate(session *discordgo.Session, event *discordgo.Vo
return
}

var guildID *snowflake.ID
if event.GuildID != "" {
id := snowflake.MustParse(event.GuildID)
guildID = &id
var channelID *snowflake.ID
if event.ChannelID != "" {
id := snowflake.MustParse(event.ChannelID)
channelID = &id
}
b.Lavalink.OnVoiceStateUpdate(context.TODO(), snowflake.MustParse(event.GuildID), guildID, event.SessionID)
b.Lavalink.OnVoiceStateUpdate(context.TODO(), snowflake.MustParse(event.GuildID), channelID, event.SessionID)
if event.ChannelID == "" {
b.Queues.Delete(event.GuildID)
}
Expand Down
6 changes: 6 additions & 0 deletions _examples/disgo/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ func (b *Bot) onApplicationCommand(event *events.ApplicationCommandInteractionCr
}

func (b *Bot) onVoiceStateUpdate(event *events.GuildVoiceStateUpdate) {
if event.VoiceState.UserID != b.Client.ApplicationID() {
return
}
b.Lavalink.OnVoiceStateUpdate(context.TODO(), event.VoiceState.GuildID, event.VoiceState.ChannelID, event.VoiceState.SessionID)
if event.VoiceState.ChannelID == nil {
b.Queues.Delete(event.VoiceState.GuildID)
}
}

func (b *Bot) onVoiceServerUpdate(event *events.VoiceServerUpdate) {
Expand Down

0 comments on commit 55eafb8

Please sign in to comment.