2021-06-25 19:29:14 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/diamondburned/arikawa/v3/discord"
|
|
|
|
"github.com/diamondburned/arikawa/v3/utils/httputil"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SearchData struct {
|
2023-08-07 19:18:35 +00:00
|
|
|
Offset uint `schema:"offset,omitempty"`
|
|
|
|
Content string `schema:"content,omitempty"`
|
|
|
|
Has string `schema:"has,omitempty"`
|
|
|
|
SortBy string `schema:"sort_by,omitempty"`
|
|
|
|
SortOrder string `schema:"sort_order,omitempty"`
|
|
|
|
ChannelID discord.ChannelID `schema:"channel_id,omitempty"`
|
|
|
|
AuthorID discord.UserID `schema:"author_id,omitempty"`
|
|
|
|
Mentions discord.UserID `schema:"mentions,omitempty"`
|
|
|
|
MaxID discord.MessageID `schema:"max_id,omitempty"`
|
|
|
|
MinID discord.MessageID `schema:"min_id,omitempty"`
|
|
|
|
IncludeNSFW bool `schema:"include_nsfw,omitempty"`
|
2021-06-25 19:29:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SearchResponse struct {
|
|
|
|
AnalyticsID string `json:"analytics_id"`
|
|
|
|
Messages [][]discord.Message `json:"messages"`
|
|
|
|
TotalResults uint `json:"total_results"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search searches through a guild's messages. It only works for user accounts.
|
|
|
|
func (c *Client) Search(guildID discord.GuildID, data SearchData) (SearchResponse, error) {
|
|
|
|
var resp SearchResponse
|
|
|
|
|
|
|
|
return resp, c.RequestJSON(
|
|
|
|
&resp, "GET",
|
|
|
|
EndpointGuilds+guildID.String()+"/messages/search",
|
|
|
|
httputil.WithSchema(c, data),
|
|
|
|
)
|
|
|
|
}
|
2024-07-13 19:41:31 +00:00
|
|
|
|
|
|
|
// SearchDirectMessages searches through a direct message channel.
|
|
|
|
// SearchData.ChannelID must be a valid channel ID.
|
|
|
|
func (c *Client) SearchDirectMessages(data SearchData) (SearchResponse, error) {
|
|
|
|
var resp SearchResponse
|
|
|
|
|
|
|
|
return resp, c.RequestJSON(
|
|
|
|
&resp, "GET",
|
|
|
|
EndpointChannels+data.ChannelID.String()+"/messages/search",
|
|
|
|
httputil.WithSchema(c, data),
|
|
|
|
)
|
|
|
|
}
|