mirror of
https://github.com/diamondburned/cchat-mock.git
synced 2025-05-06 13:44:22 +00:00
Fixed randomOldMsg out of bounds
This commit is contained in:
parent
b37eee0bea
commit
b36f8f47de
|
@ -255,7 +255,7 @@ func (ch *Channel) randomOldMsg() Message {
|
|||
defer ch.messageMutex.Unlock()
|
||||
|
||||
// Pick a random index from last, clamped to 10 and len channel.
|
||||
n := len(ch.messageids) - rand.Intn(len(ch.messageids))%10
|
||||
n := len(ch.messageids) - 1 - rand.Intn(len(ch.messageids))%10
|
||||
return ch.messages[ch.messageids[n]]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue