Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: allow omission of Limit on PublicArchivedThreadsBefore #348

Merged
merged 1 commit into from
Oct 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}