Merge pull request #800 from adityaxdiwakar/master
Add support for news channels
This commit is contained in:
commit
7b0771c3d7
3 changed files with 45 additions and 0 deletions
|
@ -112,6 +112,8 @@ var (
|
||||||
EndpointChannelMessagesBulkDelete = func(cID string) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
|
EndpointChannelMessagesBulkDelete = func(cID string) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
|
||||||
EndpointChannelMessagesPins = func(cID string) string { return EndpointChannel(cID) + "/pins" }
|
EndpointChannelMessagesPins = func(cID string) string { return EndpointChannel(cID) + "/pins" }
|
||||||
EndpointChannelMessagePin = func(cID, mID string) string { return EndpointChannel(cID) + "/pins/" + mID }
|
EndpointChannelMessagePin = func(cID, mID string) string { return EndpointChannel(cID) + "/pins/" + mID }
|
||||||
|
EndpointChannelMessageCrosspost = func(cID, mID string) string { return EndpointChannel(cID) + "/messages/" + mID + "/crosspost" }
|
||||||
|
EndpointChannelFollow = func(cID string) string { return EndpointChannel(cID) + "/followers" }
|
||||||
|
|
||||||
EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }
|
EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }
|
||||||
|
|
||||||
|
|
37
restapi.go
37
restapi.go
|
@ -1790,6 +1790,43 @@ func (s *Session) ChannelPermissionDelete(channelID, targetID string) (err error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChannelMessageCrosspost cross posts a message in a news channel to followers
|
||||||
|
// of the channel
|
||||||
|
// channelID : The ID of a Channel
|
||||||
|
// messageID : The ID of a Message
|
||||||
|
func (s *Session) ChannelMessageCrosspost(channelID, messageID string) (st *Message, err error) {
|
||||||
|
|
||||||
|
endpoint := EndpointChannelMessageCrosspost(channelID, messageID)
|
||||||
|
|
||||||
|
body, err := s.RequestWithBucketID("POST", endpoint, nil, endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = unmarshal(body, &st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChannelNewsFollow follows a news channel in the targetID
|
||||||
|
// channelID : The ID of a News Channel
|
||||||
|
// targetID : The ID of a Channel where the News Channel should post to
|
||||||
|
func (s *Session) ChannelNewsFollow(channelID, targetID string) (st *ChannelFollow, err error) {
|
||||||
|
|
||||||
|
endpoint := EndpointChannelFollow(channelID)
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
WebhookChannelID string `json:"webhook_channel_id"`
|
||||||
|
}{targetID}
|
||||||
|
|
||||||
|
body, err := s.RequestWithBucketID("POST", endpoint, data, endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = unmarshal(body, &st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Functions specific to Discord Invites
|
// Functions specific to Discord Invites
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -316,6 +316,12 @@ type ChannelEdit struct {
|
||||||
RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
|
RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A ChannelFollow holds data returned after following a news channel
|
||||||
|
type ChannelFollow struct {
|
||||||
|
ChannelID string `json:"channel_id"`
|
||||||
|
WebhookID string `json:"webhook_id"`
|
||||||
|
}
|
||||||
|
|
||||||
// A PermissionOverwrite holds permission overwrite data for a Channel
|
// A PermissionOverwrite holds permission overwrite data for a Channel
|
||||||
type PermissionOverwrite struct {
|
type PermissionOverwrite struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
|
Loading…
Reference in a new issue