mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-12-01 03:03:48 +00:00
state: Fix Messages() OOB panic
This commit is contained in:
parent
ec4cd6d661
commit
34db90a16d
|
@ -603,7 +603,7 @@ func (s *State) Message(
|
||||||
// first. The returned slice will be sorted from latest to oldest.
|
// first. The returned slice will be sorted from latest to oldest.
|
||||||
func (s *State) Messages(channelID discord.ChannelID, limit uint) ([]discord.Message, error) {
|
func (s *State) Messages(channelID discord.ChannelID, limit uint) ([]discord.Message, error) {
|
||||||
storeMessages, err := s.Cabinet.Messages(channelID)
|
storeMessages, err := s.Cabinet.Messages(channelID)
|
||||||
if err == nil && s.tracksMessage(&storeMessages[0]) {
|
if len(storeMessages) > 0 && s.tracksMessage(&storeMessages[0]) {
|
||||||
// Is the channel tiny?
|
// Is the channel tiny?
|
||||||
s.fewMutex.Lock()
|
s.fewMutex.Lock()
|
||||||
if _, ok := s.fewMessages[channelID]; ok {
|
if _, ok := s.fewMessages[channelID]; ok {
|
||||||
|
|
Loading…
Reference in a new issue