MarcusOtter / discord-needle

Needle is a Discord bot that creates Discord threads automatically.

Home Page:https://needle.gg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🐛 Too many permission overrides makes Needle slow

MarcusOtter opened this issue · comments

Describe the bug

Having this many channel overrides causes Needle to take more than 3 seconds to reply, which leads to an error on Discord's end.

image

Steps to reproduce the bug

  1. Add about as many channels overrides you see in the image above
  2. Create a thread
  3. Try to close the thread
  4. See "this interaction failed" (error "Unknown interaction" shows up in console a few seconds later)

Expected behavior

It should work under 3 seconds regardless of how many overrides you have.

A short term fix is to acknowledge the interaction which gives us more than 3 seconds to respond.
But in the long term it should definitely not take more than 3 seconds for Needle to react to a command like this, so we need to improve the performance of the permission check a lot.

@MarcusOtter Please assign to me, I can investigate.

Sure! The problem should be this method here. I know we can at restructure this and Promise.all, but there may be other performance improvements too (for example, don't fetch the member roles in every iteration for the roles here)

We cannot parallelize that fetch- we will quickly run into rate limits. I don't think we need that fetch, I will investigate.

Any updates @c43721?