Skip to content

Commit

Permalink
api: *ArchivedThreadsBefore to *ArchivedThreads, allow empty Limit
Browse files Browse the repository at this point in the history
  • Loading branch information
samhza authored and diamondburned committed Oct 2, 2022
1 parent dc54548 commit 3ae45b7
Showing 1 changed file with 41 additions and 11 deletions.
52 changes: 41 additions & 11 deletions api/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ type ArchivedThreads struct {
More bool `json:"has_more"`
}

// PublicArchivedThreadsBefore returns archived threads in the channel that are
// PublicArchivedThreads returns archived threads in the channel that are
// public.
//
// When called on a GUILD_TEXT channel, returns threads of type
Expand All @@ -525,13 +525,13 @@ type ArchivedThreads struct {
// Threads are ordered by ArchiveTimestamp, in descending order.
//
// Requires the READ_MESSAGE_HISTORY permission.
func (c *Client) PublicArchivedThreadsBefore(
func (c *Client) PublicArchivedThreads(
channelID discord.ChannelID,
before discord.Timestamp, limit uint) (*ArchivedThreads, error) {

var param struct {
Before string `schema:"before,omitempty"`
Limit uint `schema:"limit"`
Limit uint `schema:"limit,omitempty"`
}

if before.IsValid() {
Expand All @@ -547,19 +547,19 @@ func (c *Client) PublicArchivedThreadsBefore(
)
}

// PrivateArchivedThreadsBefore returns archived threads in the channel that
// are of type GUILD_PRIVATE_THREAD.
// PrivateArchivedThreads returns archived threads in the channel that are of
// type GUILD_PRIVATE_THREAD.
//
// Threads are ordered by ArchiveTimestamp, in descending order.
//
// Requires both the READ_MESSAGE_HISTORY and MANAGE_THREADS permissions.
func (c *Client) PrivateArchivedThreadsBefore(
func (c *Client) PrivateArchivedThreads(
channelID discord.ChannelID,
before discord.Timestamp, limit uint) (*ArchivedThreads, error) {

var param struct {
Before string `schema:"before,omitempty"`
Limit uint `schema:"limit"`
Limit uint `schema:"limit,omitempty"`
}

if before.IsValid() {
Expand All @@ -575,19 +575,19 @@ func (c *Client) PrivateArchivedThreadsBefore(
)
}

// JoinedPrivateArchivedThreadsBefore returns archived threads in the channel
// that are of type GUILD_PRIVATE_THREAD, and the user has joined.
// JoinedPrivateArchivedThreads returns archived threads in the channel that are
// of type GUILD_PRIVATE_THREAD, and the user has joined.
//
// Threads are ordered by their ID, in descending order.
//
// Requires the READ_MESSAGE_HISTORY permission
func (c *Client) JoinedPrivateArchivedThreadsBefore(
func (c *Client) JoinedPrivateArchivedThreads(
channelID discord.ChannelID,
before discord.Timestamp, limit uint) (*ArchivedThreads, error) {

var param struct {
Before string `schema:"before,omitempty"`
Limit uint `schema:"limit"`
Limit uint `schema:"limit,omitempty"`
}

if before.IsValid() {
Expand All @@ -602,3 +602,33 @@ func (c *Client) JoinedPrivateArchivedThreadsBefore(
httputil.WithSchema(c, param),
)
}

// PublicArchivedThreadsBefore returns archived threads in the channel that are
// public.
//
// Deprecated: Use PublicArchivedThreads instead.
func (c *Client) PublicArchivedThreadsBefore(
channelID discord.ChannelID,
before discord.Timestamp, limit uint) (*ArchivedThreads, error) {
return c.PublicArchivedThreads(channelID, before, limit)
}

// PrivateArchivedThreadsBefore returns archived threads in the channel that
// are of type GUILD_PRIVATE_THREAD.
//
// Deprecated: Use PrivateArchivedThreads instead.
func (c *Client) PrivateArchivedThreadsBefore(
channelID discord.ChannelID,
before discord.Timestamp, limit uint) (*ArchivedThreads, error) {
return c.PrivateArchivedThreads(channelID, before, limit)
}

// JoinedPrivateArchivedThreadsBefore returns archived threads in the channel
// that are of type GUILD_PRIVATE_THREAD, and the user has joined.
//
// Deprecated: Use JoinedPrivateArchivedThreads instead.
func (c *Client) JoinedPrivateArchivedThreadsBefore(
channelID discord.ChannelID,
before discord.Timestamp, limit uint) (*ArchivedThreads, error) {
return c.JoinedPrivateArchivedThreads(channelID, before, limit)
}

0 comments on commit 3ae45b7

Please sign in to comment.