diff --git a/api/user.go b/api/user.go index 5f05248..037e684 100644 --- a/api/user.go +++ b/api/user.go @@ -100,3 +100,24 @@ func (c *Client) SetNote(userID discord.Snowflake, note string) error { 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()) +} diff --git a/discord/user.go b/discord/user.go index 58ddaa3..a0abaf0 100644 --- a/discord/user.go +++ b/discord/user.go @@ -200,3 +200,22 @@ type ActivitySecrets struct { Spectate string `json:"spectate,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 +) diff --git a/gateway/events.go b/gateway/events.go index 76c223a..e22c9a0 100644 --- a/gateway/events.go +++ b/gateway/events.go @@ -329,9 +329,9 @@ type ( type ( RelationshipAddEvent struct { - Relationship + discord.Relationship } RelationshipRemoveEvent struct { - Relationship + discord.Relationship } ) diff --git a/gateway/ready.go b/gateway/ready.go index efb17fd..5edca1b 100644 --- a/gateway/ready.go +++ b/gateway/ready.go @@ -20,7 +20,7 @@ type ReadyEvent struct { ReadState []ReadState `json:"read_state,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"` } @@ -112,20 +112,3 @@ type GuildFolder struct { GuildIDs []discord.Snowflake `json:"guild_ids"` 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 -)