kentcdodds / kcd-discord-bot-v1

The bot for the KCD discord community
https://kcd.im/discord
MIT License
122 stars 41 forks source link

Discord voice meetups incorrectly deleted #72

Open fildon opened 3 years ago

fildon commented 3 years ago

What you did:

What happened:

Problem description:

Suggested solution:

fildon commented 3 years ago

Further info: Both I and @bouwe77 have observed this. In particular @bouwe77 saw this reproduce three times in one evening. Do not have exact time stamps however the timings seem to fit with happening around every 15 minutes.

Aprillion commented 3 years ago

So, Rupert tested the bot today and the 15-minute part of the condition looks OK, so it must be that meetupChannel.members.size is 0 even if someone is in the room... getMeetupChannels() in https://github.com/fildon/kcd-discord-bot/blob/06b881370ef907cc79eb0b010d0471a104ffec91/src/meetup/utils.ts#L121 is using a cache, but that was added 4 months ago, not recently...

Could it be that some unrelated code that used to refresh the cache was removed??

Aprillion commented 3 years ago

I checked the code a little and I the most suspicious line of code is https://github.com/fildon/kcd-discord-bot/commit/2db2be725d2124fed0674b34febaa2901e2907d4#r52204857 ... @fildon do you remember if you introduced that line for a good reason or only to make TS happy? (I suspect a runtime error might have been more useful than silencing errors in that place, at least for investigating this issue heh)

fildon commented 3 years ago

I don't think I introduced that line. Looks to be a commit by @kentcdodds 🤔 Even so it doesn't look suspicious to me. It is just handling the case that guild is undefined ... which should probably never happen, but if it does it chooses to return an empty collection when trying to get meetup channels. Which means either way the function is guaranteed to return a collection. That's useful for where it is being enumerated over elsewhere.