From 22e5cd898d089e319c91f0941c42bf931cf0bf98 Mon Sep 17 00:00:00 2001 From: Magnus Jensen Date: Sat, 22 Nov 2025 11:25:03 -0300 Subject: [PATCH] feat(restapi): Add support for voice state API endpoints (#1671) --- endpoints.go | 3 +++ restapi.go | 16 ++++++++++++++++ structs.go | 1 + user.go | 1 + 4 files changed, 21 insertions(+) diff --git a/endpoints.go b/endpoints.go index 79e3bae..2bf632a 100644 --- a/endpoints.go +++ b/endpoints.go @@ -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" diff --git a/restapi.go b/restapi.go index 4e6e5d9..c93b6e7 100644 --- a/restapi.go +++ b/restapi.go @@ -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 +} diff --git a/structs.go b/structs.go index 57c6eda..35789f6 100644 --- a/structs.go +++ b/structs.go @@ -2882,6 +2882,7 @@ const ( ErrCodeUnknownSticker = 10060 ErrCodeUnknownInteraction = 10062 ErrCodeUnknownApplicationCommand = 10063 + ErrCodeUnknownVoiceState = 10065 ErrCodeUnknownApplicationCommandPermissions = 10066 ErrCodeUnknownStageInstance = 10067 ErrCodeUnknownGuildMemberVerificationForm = 10068 diff --git a/user.go b/user.go index 160df22..03eb1f1 100644 --- a/user.go +++ b/user.go @@ -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"`