Skip to content

Commit

Permalink
Add get voice state endpoints (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed Aug 7, 2024
1 parent 8f3c66b commit 8e9d18d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rest/members.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Members interface {

UpdateCurrentMember(guildID snowflake.ID, nick string, opts ...RequestOpt) (*string, error)

GetCurrentUserVoiceState(guildID snowflake.ID, opts ...RequestOpt) (*discord.VoiceState, error)
GetUserVoiceState(guildID snowflake.ID, userID snowflake.ID, opts ...RequestOpt) (*discord.VoiceState, error)
UpdateCurrentUserVoiceState(guildID snowflake.ID, currentUserVoiceStateUpdate discord.CurrentUserVoiceStateUpdate, opts ...RequestOpt) error
UpdateUserVoiceState(guildID snowflake.ID, userID snowflake.ID, userVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error
}
Expand Down Expand Up @@ -105,6 +107,16 @@ func (s *memberImpl) UpdateCurrentMember(guildID snowflake.ID, nick string, opts
return
}

func (s *memberImpl) GetCurrentUserVoiceState(guildID snowflake.ID, opts ...RequestOpt) (state *discord.VoiceState, err error) {
err = s.client.Do(GetCurrentUserVoiceState.Compile(nil, guildID), nil, &state, opts...)
return
}

func (s *memberImpl) GetUserVoiceState(guildID snowflake.ID, userID snowflake.ID, opts ...RequestOpt) (state *discord.VoiceState, err error) {
err = s.client.Do(GetUserVoiceState.Compile(nil, guildID, userID), nil, &state, opts...)
return
}

func (s *memberImpl) UpdateCurrentUserVoiceState(guildID snowflake.ID, currentUserVoiceStateUpdate discord.CurrentUserVoiceStateUpdate, opts ...RequestOpt) error {
return s.client.Do(UpdateCurrentUserVoiceState.Compile(nil, guildID), currentUserVoiceStateUpdate, nil, opts...)
}
Expand Down
2 changes: 2 additions & 0 deletions rest/rest_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ var (
GetGuildOnboarding = NewEndpoint(http.MethodGet, "/guilds/{guild.id}/onboarding")
UpdateGuildOnboarding = NewEndpoint(http.MethodPut, "/guilds/{guild.id}/onboarding")

GetCurrentUserVoiceState = NewEndpoint(http.MethodGet, "/guilds/{guild.id}/voice-states/@me")
GetUserVoiceState = NewEndpoint(http.MethodGet, "/guilds/{guild.id}/voice-states/{user.id}")
UpdateCurrentUserVoiceState = NewEndpoint(http.MethodPatch, "/guilds/{guild.id}/voice-states/@me")
UpdateUserVoiceState = NewEndpoint(http.MethodPatch, "/guilds/{guild.id}/voice-states/{user.id}")
)
Expand Down

0 comments on commit 8e9d18d

Please sign in to comment.