Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle MessageDeleteBulk event #304

Merged
merged 4 commits into from
Dec 28, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions state.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,16 @@ func (s *State) MessageAdd(message *Message) error {
}

// MessageRemove removes a message from the world state.
func (s *State) MessageRemove(channelID, messageID string) error {
func (s *State) MessageRemove(message *Message) error {
if s == nil {
return ErrNilState
}

return s.messageRemoveById(message.ChannelID, message.ID)
}

// messageRemoveById removes a message by channelID and messageID from the world state.
func (s *State) messageRemoveById(channelID, messageID string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint is complaining this should be: messageRemoveByID

c, err := s.Channel(channelID)
if err != nil {
return err
Expand Down Expand Up @@ -708,12 +713,12 @@ func (s *State) onInterface(se *Session, i interface{}) (err error) {
}
case *MessageDelete:
if s.MaxMessageCount != 0 {
err = s.MessageRemove(t.ChannelID, t.ID)
err = s.MessageRemove(t.Message)
}
case *MessageDeleteBulk:
if s.MaxMessageCount != 0 {
for _, mID := range t.Messages {
s.MessageRemove(t.ChannelID, mID)
s.messageRemoveById(t.ChannelID, mID)
}
}
case *VoiceStateUpdate:
Expand Down