From 219b1d80d65b96b72c3b90172ff420d0cdd0f184 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Sat, 1 Oct 2022 19:34:46 -0700 Subject: [PATCH] api: Fix incorrect use of ArchivedThreads This commit fixes the several ArchivedThread API getters to unmarshal to the right type. Prior to this commit, things don't work. --- api/channel.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/api/channel.go b/api/channel.go index 7e64503..f7c2160 100644 --- a/api/channel.go +++ b/api/channel.go @@ -508,12 +508,8 @@ func (c *Client) ActiveThreads(guildID discord.GuildID) (*ActiveThreads, error) // https://discord.com/developers/docs/resources/channel#list-private-archived-threads-response-body // and // https://discord.com/developers/docs/resources/channel#list-private-archived-threads-response-body -type ArchivedThread struct { - // Threads are the active threads, ordered by descending ArchiveTimestamp. - Threads []discord.Channel `json:"threads"` - // Members contains a thread member for each of the Threads the current - // user has joined. - Members []discord.ThreadMember `json:"members"` +type ArchivedThreads struct { + ActiveThreads // More specifies whether there are potentially additional threads that // could be returned on a subsequent call. More bool `json:"has_more"` @@ -531,7 +527,7 @@ type ArchivedThread struct { // Requires the READ_MESSAGE_HISTORY permission. func (c *Client) PublicArchivedThreadsBefore( channelID discord.ChannelID, - before discord.Timestamp, limit uint) ([]ArchivedThread, error) { + before discord.Timestamp, limit uint) (*ArchivedThreads, error) { var param struct { Before string `schema:"before,omitempty"` @@ -543,7 +539,7 @@ func (c *Client) PublicArchivedThreadsBefore( } param.Limit = limit - var t []ArchivedThread + var t *ArchivedThreads return t, c.RequestJSON( &t, "GET", EndpointChannels+channelID.String()+"/threads/archived/public", @@ -559,7 +555,7 @@ func (c *Client) PublicArchivedThreadsBefore( // Requires both the READ_MESSAGE_HISTORY and MANAGE_THREADS permissions. func (c *Client) PrivateArchivedThreadsBefore( channelID discord.ChannelID, - before discord.Timestamp, limit uint) ([]ArchivedThread, error) { + before discord.Timestamp, limit uint) (*ArchivedThreads, error) { var param struct { Before string `schema:"before,omitempty"` @@ -571,7 +567,7 @@ func (c *Client) PrivateArchivedThreadsBefore( } param.Limit = limit - var t []ArchivedThread + var t *ArchivedThreads return t, c.RequestJSON( &t, "GET", EndpointChannels+channelID.String()+"/threads/archived/private", @@ -587,7 +583,7 @@ func (c *Client) PrivateArchivedThreadsBefore( // Requires the READ_MESSAGE_HISTORY permission func (c *Client) JoinedPrivateArchivedThreadsBefore( channelID discord.ChannelID, - before discord.Timestamp, limit uint) ([]ArchivedThread, error) { + before discord.Timestamp, limit uint) (*ArchivedThreads, error) { var param struct { Before string `schema:"before,omitempty"` @@ -599,7 +595,7 @@ func (c *Client) JoinedPrivateArchivedThreadsBefore( } param.Limit = limit - var t []ArchivedThread + var t *ArchivedThreads return t, c.RequestJSON( &t, "GET", EndpointChannels+channelID.String()+"/users/@me/threads/archived/private",