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.
This commit is contained in:
diamondburned 2022-10-01 19:34:46 -07:00
parent 0c7539c6d5
commit 219b1d80d6
No known key found for this signature in database
GPG Key ID: D78C4471CE776659
1 changed files with 8 additions and 12 deletions

View File

@ -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",