1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-12-08 04:57:19 +00:00

Compare commits

...

4 commits

Author SHA1 Message Date
Scott 7705eda93a
Merge 29f0a1ac5b into a891a653eb 2025-10-09 15:41:57 +08:00
Ayyan a891a653eb
api: Add omitempty to SearchThreadsData (#489)
* fix(api): add omitempty to SearchThreadsData

* invalid tag
2025-09-27 17:42:12 -07:00
Ayyan 43b5c9dcad
api: Add SearchThreads function (#488) 2025-09-27 17:27:34 -07:00
twoscott 29f0a1ac5b discord: Support GIF banner URLs 2025-03-26 21:37:18 +00:00
2 changed files with 60 additions and 3 deletions

View file

@ -644,3 +644,59 @@ func (c *Client) JoinedPrivateArchivedThreadsBefore(
before discord.Timestamp, limit uint) (*ArchivedThreads, error) {
return c.JoinedPrivateArchivedThreads(channelID, before, limit)
}
type ThreadTagSetting string
const (
MatchSome ThreadTagSetting = "match_some"
MatchAll ThreadTagSetting = "all"
)
type ThreadSortBy string
const (
LastMessageTime ThreadSortBy = "last_message_time"
ArchiveTime ThreadSortBy = "archive_time"
Relevance ThreadSortBy = "relevance"
CreationTime ThreadSortBy = "creation_time"
)
type ThreadSortOrder string
const (
SortAscending ThreadSortOrder = "asc"
SortDescending ThreadSortOrder = "desc"
)
type (
SearchThreadsData struct {
Name string `schema:"name,omitempty"`
Slop int `schema:"slop,omitempty"`
Tag []discord.Snowflake `schema:"tag,omitempty"`
TagSetting ThreadTagSetting `schema:"tag_setting,omitempty"`
Archived bool `schema:"archived,omitempty"`
SortOrder ThreadSortOrder `schema:"sort_order,omitempty"`
SortBy ThreadSortBy `schema:"sort_by,omitempty"`
Limit int `schema:"limit,omitempty"`
MaxID discord.Snowflake `schema:"max_id,omitempty"`
MinID discord.Snowflake `schema:"min_id,omitempty"`
Offset int `schema:"offset,omitempty"`
}
SearchThreadsResponse struct {
Threads []discord.Channel `json:"threads"`
Members []discord.ThreadMember `json:"members"`
HasMore bool `json:"has_more"`
TotalResults int `json:"total_results"`
FirstMessages []discord.Message `json:"first_messages,omitempty"`
}
)
func (c *Client) SearchThreads(channelID discord.ChannelID, data SearchThreadsData) (SearchThreadsResponse, error) {
var resp SearchThreadsResponse
return resp, c.RequestJSON(
&resp, "GET",
EndpointChannels+channelID.String()+"/threads/search",
httputil.WithSchema(c, data),
)
}

View file

@ -142,15 +142,16 @@ func (g Guild) IconURLWithType(t ImageType) string {
}
// BannerURL returns the URL to the banner, which is the image on top of the
// channels list. This will always return a link to a PNG file.
// channels list. Auto detects a suitable image type. An empty string is
// returned if the guild has no banner.
func (g Guild) BannerURL() string {
return g.BannerURLWithType(PNGImage)
return g.BannerURLWithType(AutoImage)
}
// BannerURLWithType returns the URL to the banner, which is the image on top
// of the channels list using the passed image type.
//
// Supported ImageTypes: PNG, JPEG, WebP
// Supported ImageTypes: PNG, JPEG, WebP, GIF
func (g Guild) BannerURLWithType(t ImageType) string {
if g.Banner == "" {
return ""