mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-12-01 03:03:48 +00:00
Discord: Added Relationship API methods; moved structs around
This commit is contained in:
parent
56b1a7cce8
commit
7572caad31
21
api/user.go
21
api/user.go
|
@ -100,3 +100,24 @@ func (c *Client) SetNote(userID discord.Snowflake, note string) error {
|
||||||
httputil.WithJSONBody(body),
|
httputil.WithJSONBody(body),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRelationship sets the relationship type between the current user and the
|
||||||
|
// given user.
|
||||||
|
func (c *Client) SetRelationship(userID discord.Snowflake, t discord.RelationshipType) error {
|
||||||
|
var body = struct {
|
||||||
|
Type discord.RelationshipType `json:"type"`
|
||||||
|
}{
|
||||||
|
Type: t,
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.FastRequest(
|
||||||
|
"PUT", EndpointMe+"/relationships/"+userID.String(),
|
||||||
|
httputil.WithJSONBody(body),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRelationship deletes the relationship between the current user and the
|
||||||
|
// given user.
|
||||||
|
func (c *Client) DeleteRelationship(userID discord.Snowflake) error {
|
||||||
|
return c.FastRequest("DELETE", EndpointMe+"/relationships/"+userID.String())
|
||||||
|
}
|
||||||
|
|
|
@ -200,3 +200,22 @@ type ActivitySecrets struct {
|
||||||
Spectate string `json:"spectate,omitempty"`
|
Spectate string `json:"spectate,omitempty"`
|
||||||
Match string `json:"match,omitempty"`
|
Match string `json:"match,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A Relationship between the logged in user and the user in the struct. This
|
||||||
|
// struct is undocumented.
|
||||||
|
type Relationship struct {
|
||||||
|
UserID Snowflake `json:"id"`
|
||||||
|
User User `json:"user"`
|
||||||
|
Type RelationshipType `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RelationshipType is an enum for a relationship.
|
||||||
|
type RelationshipType uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
_ RelationshipType = iota
|
||||||
|
FriendRelationship
|
||||||
|
BlockedRelationship
|
||||||
|
IncomingFriendRequest
|
||||||
|
SentFriendRequest
|
||||||
|
)
|
||||||
|
|
|
@ -329,9 +329,9 @@ type (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
RelationshipAddEvent struct {
|
RelationshipAddEvent struct {
|
||||||
Relationship
|
discord.Relationship
|
||||||
}
|
}
|
||||||
RelationshipRemoveEvent struct {
|
RelationshipRemoveEvent struct {
|
||||||
Relationship
|
discord.Relationship
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,7 +20,7 @@ type ReadyEvent struct {
|
||||||
ReadState []ReadState `json:"read_state,omitempty"`
|
ReadState []ReadState `json:"read_state,omitempty"`
|
||||||
Presences []discord.Presence `json:"presences,omitempty"`
|
Presences []discord.Presence `json:"presences,omitempty"`
|
||||||
|
|
||||||
Relationships []Relationship `json:"relationships,omitempty"`
|
Relationships []discord.Relationship `json:"relationships,omitempty"`
|
||||||
Notes map[discord.Snowflake]string `json:"notes,omitempty"`
|
Notes map[discord.Snowflake]string `json:"notes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,20 +112,3 @@ type GuildFolder struct {
|
||||||
GuildIDs []discord.Snowflake `json:"guild_ids"`
|
GuildIDs []discord.Snowflake `json:"guild_ids"`
|
||||||
Color discord.Color `json:"color"`
|
Color discord.Color `json:"color"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Relationship between the logged in user and Relationship.User
|
|
||||||
type Relationship struct {
|
|
||||||
UserID discord.Snowflake `json:"id"`
|
|
||||||
User discord.User `json:"user"`
|
|
||||||
Type RelationshipType `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RelationshipType uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
_ RelationshipType = iota
|
|
||||||
FriendRelationship
|
|
||||||
BlockedRelationship
|
|
||||||
IncomingFriendRequest
|
|
||||||
SentFriendRequest
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue