From 9f24531220f48720555bea63cdd0d00c25c3e7e6 Mon Sep 17 00:00:00 2001 From: jonas747 Date: Thu, 13 Oct 2016 21:42:05 +0200 Subject: [PATCH] Update ChannelMessageAck because of api changes (#270) --- restapi.go | 10 ++++++++-- structs.go | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/restapi.go b/restapi.go index 3214556..2e2adf2 100644 --- a/restapi.go +++ b/restapi.go @@ -1127,9 +1127,15 @@ func (s *Session) ChannelMessage(channelID, messageID string) (st *Message, err // ChannelMessageAck acknowledges and marks the given message as read // channeld : The ID of a Channel // messageID : the ID of a Message -func (s *Session) ChannelMessageAck(channelID, messageID string) (err error) { +// lastToken : token returned by last ack +func (s *Session) ChannelMessageAck(channelID, messageID, lastToken string) (st *Ack, err error) { - _, err = s.request("POST", EndpointChannelMessageAck(channelID, messageID), "", nil, 0) + body, err := s.Request("POST", EndpointChannelMessageAck(channelID, messageID), &Ack{Token: lastToken}) + if err != nil { + return + } + + err = unmarshal(body, &st) return } diff --git a/structs.go b/structs.go index 88352d9..3e0c375 100644 --- a/structs.go +++ b/structs.go @@ -408,6 +408,11 @@ type MessageAck struct { ChannelID string `json:"channel_id"` } +// An Ack is used to ack messages +type Ack struct { + Token string `json:"token"` +} + // A GuildIntegrationsUpdate stores data for the guild integrations update // websocket event. type GuildIntegrationsUpdate struct {