feat(restapi): Add support for voice state API endpoints (#1671)

This commit is contained in:
Magnus Jensen
2025-11-22 11:25:03 -03:00
committed by GitHub
parent c144aa1605
commit 22e5cd898d
4 changed files with 21 additions and 0 deletions

View File

@@ -121,6 +121,9 @@ var (
EndpointGuildMemberBannerAnimated = func(gId, uID, hash string) string {
return EndpointCDNGuilds + gId + "/users/" + uID + "/banners/" + hash + ".gif"
}
EndpointGuildMemberVoiceState = func(gID, uID string) string {
return EndpointGuild(gID) + "/voice-states/" + uID
}
EndpointRoleIcon = func(rID, hash string) string {
return EndpointCDNRoleIcons + rID + "/" + hash + ".png"

View File

@@ -3745,3 +3745,19 @@ func (s *Session) Subscription(skuID, subscriptionID, userID string, options ...
err = unmarshal(body, &subscription)
return
}
// UserVoiceState returns the voice state of the current user (the bot) in a guild.
// guildID : The ID of the guild.
// userID : The ID of the user.
// Note: Using @me will return the bot's voice state for the given guild.
func (s *Session) UserVoiceState(guildID string, userID string, options ...RequestOption) (state *VoiceState, err error) {
endpoint := EndpointGuildMemberVoiceState(guildID, userID)
body, err := s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
err = unmarshal(body, &state)
return
}

View File

@@ -2882,6 +2882,7 @@ const (
ErrCodeUnknownSticker = 10060
ErrCodeUnknownInteraction = 10062
ErrCodeUnknownApplicationCommand = 10063
ErrCodeUnknownVoiceState = 10065
ErrCodeUnknownApplicationCommandPermissions = 10066
ErrCodeUnknownStageInstance = 10067
ErrCodeUnknownGuildMemberVerificationForm = 10068

View File

@@ -40,6 +40,7 @@ const (
UserPremiumTypeNitroBasic UserPremiumType = 3
)
// UserPrimaryGuild represents a user's primary guild information.
type UserPrimaryGuild struct {
// The ID of the user's primary guild.
IdentityGuildID string `json:"identity_guild_id"`