-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with updating TextChannel Topic #4327
Comments
This is not because of caching or the like, it's "just" you being rate limited. There was an announcement about this on the official Discord Developers guild:
|
I didn't know, so I close |
However, in this case it could throw an error in catch |
So this cannot be bypassed. We will have to work around it, correct ? |
This should absolutely be mentioned in the documentation, especially since it didn't used to be the case. I just wasted half an hour debugging my bot that used to work fine before finding this thread. It could at least throw an error though rather than just not doing anything at all. Super confusing. |
No, ratelimits aren't mentioned in any other part of the documentation and also shouldn't be in this case. Discord.js isn't supposed to warn you about changes on Discord's end that don't affect the usage of the library. |
But it should throw an error, and not I am waiting and promise is always pending |
The problem is that "changes on Discord's end" DO "affect the usage of the library". And I don't see why you wouldn't want to make the documentation as helpful as possible to the people using the library (at the very least. it would still be far better if it just threw an error, rather than doing NOTHING which no code should ever do) |
👎 There is no error thrown because the library has not yet given up on the HTTP request. Every request that replies with a code In your cases, it fails once with a rate limit, which makes it wait for its duration & re-tries afterwards, most likely succeeding. |
Throwing an error
You are suggesting that instead of delaying rate limited actions and sending them when the rate limit backoff is over we should just throw an error when ever you are experiencing a rate limit? One of the major points of using a library is to actually not have to deal with rate limits (along with getting the cached data and valid structures when websocket events emit). Throwing an error every time a action can not be immediately executed would be an absolutely terrible user experience and make the point of handling the rate limit backoff obsolete. If you are of a different opinion you seem to be lacking understanding of how rate limits work and why they are dynamically computed by the API. Feel free to review discords API documentation on the topic. Which leads us to the next point: Documenting rate limitsRate limits are dynamically set by the API based on current load. Approximations in rate limits can be made over time however it might change at any point during operation without further notice. Discord themselves do not document rate limits. The stance is the following: Or the actual quote from discords API documentation (emphasis by me) :
There are approximations of certain endpoints limits floating around the internet and in the case of topic and name changes it turns out to be roughly 2 per 10 minutes, however nothing guarantees that these values will stay. Documenting rate limits on our (library) end is just not feasible. Doing NothingThe library returns a promise, a promise represents "the eventual completion (or failure) of an asynchronous operation, and its resulting value.", which is precisely what's happening here. After the back off the request will be made and the promise will resolve. If an API error occurs the promise will reject, as per specification. And lastly: Bypassing/Working around rate limitsNo. And if you don't want the same to happen to channel creation or other endpoints you best don't apply the same logic to other endpoints. This was a deliberate update to stop bots from editing channels every x seconds as clocks, timers, ping displays, dynamically changing member statistics and whatever other applications for it exist(ed). This follows directly after people abusing role color changes for "rainbow roles". A subset of people abuses endpoints and now we have to deal with exorbitantly high channel name and topic change limits. |
We don't wanna update the documentation all the time in case they change their ratelimits and do not announce it. It would simply be wrong and someone would open an issue like this again. Lets just not build clocks or real-time updates into channel names/topics or any other real-time shenanigans, shall we? Soujis explanation should cover the rest. I'll close this since there is really no need for a discussion around this anymore. |
Please describe the problem you are having in as much detail as possible:
My bot updating 6 channels' topics every minute. I've never had problems with it. Today I noticed that the topics are not refreshing every minute, but randomly (after 5 or 10 minutes). I don't have any errors on the console. I thought it might be because the channels are not in the cache.
I quickly prepared a version using:
but the effect was the same. Because setTopic returns Promise I added .then():
and even he doesn't call.
Further details:
The text was updated successfully, but these errors were encountered: