Very intense application command fetching
I'm using the new sapphire, v4.0.1 , with discord js v14.7.1
Suddenly, the the bot does an incredible amount of fetching of application commands, resulting in rate limit.
{"timeToReset":1100,"limit":50,"method":"GET","hash":"Global(GET:/applications/:id/commands)","url":"https://discord.com/api/v10/applications/ID/commands?with_localizations=true","route":"/applications/:id/commands","majorParameter":"global","global":true}
I have no clue why as I do not use any application commands. Neither any clue to what triggers it.
It could be a discord.js problem of course but since I dont have any code at all relating to application commands, I think it's more likely sapphire?Solution:Jump to solution
@bomi can you test the changes made in the PR release if they achieve the same end result?
...
GitHub
fix(Command): Do not attempt to execute application command reloadi...
Back in v2.5.1 the Command class did not have an overwritten reload method at all: https://github.com/sapphiredev/framework/blob/v2.5.1/src/lib/structures/Command.ts
This suggests that we didn'...
37 Replies
Is there a way to disable application command registries?
@Favna this sounds interesting
Do you know some more logging I could add around this, I am not familiar with the ApplicationCommandRegistries
there is no way to disable it but if there are no commands to register then it simply does nothing
there is basically an
if (!something.length) return
in there
like it's one of the first lines calledAnd it only adds the command to the array/map/etc to be processed if you call something like this?
correct
It has happened... Hmm, about 5 times now
@Vladdy tbh
What if there is some old slash command registered on discord could that affect it?
I'm gonna need a bit more than this, as we only fetch global commands once on ready, and then whenever a command or a store is reloaded
Oh oh oh
Also hitting the ratelimit isn't a big deal unless it slows down some other code, djs handles them for you already
Yes I have been reloading
How often have you been reloading
Unfortunately in this case there was 10k calls resulting in global rate limit
Uh yeah so that's not what the 10k limit is
10k limit is for 403 or 401, aka missing access or missing permissions
10k 429s in 10 minutes sounds kinda impossible
could it be that we don't properly check if it should register at all when calling
command#reload
tho ?Actuall yeah sorry. I havent counted them. But I am looking at the lines in the rate limit log. There was 10k lines of rate limit logging
This is what I do hehe
Oh god
Please just use commands.reloadAll()
If you want to reload all commands
like this?
Ye
I don't remember fully if that's the method name
Im scared
@Favna maybe you can help as I'm currently away from laptop
There is CommandStore.loadAll() ?
Yes
Which i haven't updated to support bulk overwrite fuck me
Well I don't know that much about this code and how it works but it seems like it fetches the application commands from discord upon reload
I dont really dare trying it but I think the problem is replicable
ill see what I can find after I finish 2 more cyberpunk missions and have dinner
been meaning to look into reload because of bulk overwrite anyway
there is 10k servers about 120 commands, 16-32 shards
thought you said you dont use application commands?
Yes, sorry. 0 Application commands, 120 message.content commands
yeah those dont care outside of the using loadAll vs reload
I think that a command type can be determined Like so
command.supportsChatInputCommands()
So I am tempted to try this modified version of reload()
This modifiaction was seemingly successful.hmmmmmmmmmmmmmmmmm
Its probably not the way you would want it, but I think it would be nice if reload had this check
Solution
@bomi can you test the changes made in the PR release if they achieve the same end result?
https://github.com/sapphiredev/framework/pull/598
Edit: Resolved with this PR, will be released in v4.1.0
GitHub
fix(Command): Do not attempt to execute application command reloadi...
Back in v2.5.1 the Command class did not have an overwritten reload method at all: https://github.com/sapphiredev/framework/blob/v2.5.1/src/lib/structures/Command.ts
This suggests that we didn'...
I can
But it would be nice if there was someway I could log any times the bot tries to fetch application command endpoints to make testing safer but idk how to
I'll just... Take the chance..
Hmm trying it on one shard only I did not see any problem
It seems to be successful on all shards.
Thanks!!
good then we can merge it