qeled / discordie

Predictable JavaScript abstractions for Discord API.
https://qeled.github.io/discordie/
BSD 2-Clause "Simplified" License
190 stars 45 forks source link

Channel objects sometimes just disappear from the cache #89

Closed TheBITLINK closed 7 years ago

TheBITLINK commented 7 years ago

Sometimes channel objects disappear from the cache (they become null), making it impossible to send messages on some guilds until i restart the shard. I don't know the details, but the quickest way to achieve this is by making a setInterval() that sends messages to a channel until it crashes.

I tried this on 2 instances of the same bot and they both had this in the logs.

image

Both instances took around the same amount of time to crash. (~30 minutes, with a 2000ms interval between messages)

qeled commented 7 years ago

You didn't provide any code samples, so I hope you're not relying on msg.channel in that eval, because when the message gets uncached (eventually, due to channel cache limits, and default limit is 1000) msg becomes an invalid reference, thus msg.channel will return null. Store the actual channel in a variable before accessing it from any async callbacks.

TheBITLINK commented 7 years ago

I did use msg.channel in this case, however, it happened to me under other circumstances as well, i'm clusing this until i have further details