1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-05-22 07:11:16 +00:00

API: stay within the boundaries of messageIDs (#160)

This commit is contained in:
Ethien Duckett 2020-11-11 14:07:30 -05:00 committed by GitHub
parent cc1975988d
commit 456692da93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -347,9 +347,10 @@ func (c *Client) DeleteMessages(channelID discord.ChannelID, messageIDs []discor
return c.deleteMessages(channelID, messageIDs)
}
// If the number of messages to be deleted exceeds the amount discord is willing
// to accept at one time then batches of messages will be deleted
for start := 0; start < len(messageIDs); start += maxMessageDeleteLimit {
end := min(len(messageIDs), maxMessageDeleteLimit)
end := min(len(messageIDs), start+maxMessageDeleteLimit)
err := c.deleteMessages(channelID, messageIDs[start:end])
if err != nil {
return err