2020-01-06 03:48:39 +00:00
|
|
|
package api
|
|
|
|
|
2020-01-06 05:22:26 +00:00
|
|
|
import (
|
|
|
|
"github.com/diamondburned/arikawa/discord"
|
2020-04-09 02:28:40 +00:00
|
|
|
"github.com/diamondburned/arikawa/utils/httputil"
|
2020-01-06 05:22:26 +00:00
|
|
|
)
|
2020-01-06 03:48:39 +00:00
|
|
|
|
2020-04-19 16:30:12 +00:00
|
|
|
var (
|
|
|
|
EndpointUsers = Endpoint + "users/"
|
|
|
|
EndpointMe = EndpointUsers + "@me"
|
|
|
|
)
|
2020-01-06 03:48:39 +00:00
|
|
|
|
|
|
|
func (c *Client) User(userID discord.Snowflake) (*discord.User, error) {
|
|
|
|
var u *discord.User
|
|
|
|
return u, c.RequestJSON(&u, "GET",
|
|
|
|
EndpointUsers+userID.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) Me() (*discord.User, error) {
|
|
|
|
var me *discord.User
|
|
|
|
return me, c.RequestJSON(&me, "GET", EndpointMe)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ModifySelfData struct {
|
|
|
|
Username string `json:"username,omitempty"`
|
|
|
|
Avatar Image `json:"image,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) ModifyMe(data ModifySelfData) (*discord.User, error) {
|
|
|
|
var u *discord.User
|
|
|
|
return u, c.RequestJSON(&u, "PATCH", EndpointMe)
|
|
|
|
}
|
|
|
|
|
2020-01-07 06:45:29 +00:00
|
|
|
func (c *Client) PrivateChannels() ([]discord.Channel, error) {
|
|
|
|
var dms []discord.Channel
|
|
|
|
return dms, c.RequestJSON(&dms, "GET", EndpointMe+"/channels")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) CreatePrivateChannel(
|
|
|
|
recipient discord.Snowflake) (*discord.Channel, error) {
|
|
|
|
|
|
|
|
var param struct {
|
|
|
|
RecipientID discord.Snowflake `json:"recipient_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
param.RecipientID = recipient
|
|
|
|
|
|
|
|
var dm *discord.Channel
|
|
|
|
return dm, c.RequestJSON(&dm, "POST", EndpointMe+"/channels",
|
|
|
|
httputil.WithJSONBody(c, param))
|
|
|
|
}
|
|
|
|
|
2020-01-16 04:27:57 +00:00
|
|
|
// ChangeOwnNickname only replies with the nickname back, so we're not even
|
|
|
|
// going to bother.
|
|
|
|
func (c *Client) ChangeOwnNickname(
|
|
|
|
guildID discord.Snowflake, nick string) error {
|
|
|
|
|
|
|
|
var param struct {
|
|
|
|
Nick string `json:"nick"`
|
|
|
|
}
|
|
|
|
|
|
|
|
param.Nick = nick
|
|
|
|
|
|
|
|
return c.FastRequest(
|
|
|
|
"PATCH",
|
|
|
|
EndpointGuilds+guildID.String()+"/members/@me/nick",
|
|
|
|
httputil.WithJSONBody(c, param),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-01-07 06:45:29 +00:00
|
|
|
// shitty SDK, don't care, PR welcomed
|
|
|
|
// func (c *Client) CreateGroup(tokens []string, nicks map[])
|
|
|
|
|
2020-01-15 04:43:34 +00:00
|
|
|
// func (c *Client) UserConnections() ([]discord.Connection, error) {}
|