Globally setting the guild in which to register commands by default
Even though I'm setting
ApplicationCommandRegistries.setDefaultGuildIds(<GUILD_ID>);
before <SapphireClient>.login
the commands are still being registered globally. The commands do not have the guildIds
option set.Solution:Jump to solution
GitHub
fix: resolved issue with registerOptions not picking up default opt...
Relates to this discord thread
78 Replies
Which type of overwrite are you using?
Sorry could you clarify what you mean by overwrite?
Are you using BulkOverwrite, Verbose overwrite, or not configured anything so the default.
The behaviorIfIdentical
The default one, haven't configured it
Righhttt... I'm 200% sure this was tested to work. Please show code. The more the better. Also @vladdy
...I sure hope you're calling setDefaultGuildIds with an array
I've double-checked and yes I am, also tried using the exact same value in the
guildIds
option of the actual command's registerChatInputCommand
call and it works as expectedthat is strange, I use that in highlights dev and it works fine
do you call that set before or after calling client.login?
We have a tag for this
What the hell?
discord moment
So here's how I am doing it:
And the command:
hmmm
and what do the logs say
also which behaviorWhenMissing are you using? just the default one?
Yes the default one
Hold on I'll reproduce it and get the logs
oh also, share the sapphire version pls
Here are the logs:
Also make sure you've installed the package.json dependencies (run your install command again) and make sure you are running the latest compiled TS code (nuke dist and if you have it tsconfig.tsbuildinfo then rebuild)
On it
(i've had that non-nuked dist bite my ass before)
I think we all have tbh
Last time I had a similar "mystery" issue not deleting
tsconfig.tsbuildinfo
was the culprit
Deleted node_modules
, reinstalled dependencies, deleted dist
and tsconfig.tsbuildinfo
, re-built dist files, didn't resolve it though, logs:
FWIW you can make it be written to dist so deleting the folder is all you need to do.
compilerOptions.tsBuildInfoFile
set it to sth like dist/tsbuildinfo.json
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
Just double-checking, this is the right import for the
ApplicationCommandRegistries
when calling its setDefaultGuildIds
method right?
Yez
Didn't know this, awesome
Out of curiosity any particular reason why this option isn't set on
@sapphire/ts-config
?different outdirs can be provided
and that'd break
Ah of course makes sense
I'm a bit stuck on your problem tbh. I'd have to review the sapphire code to give proper guidance but doing so from mobile is a big no. Way too PITA.
can you log what your this._environment.GUILD_IDS.split(',') returns?
huh
Could it have anything to do with the fact the command in question extends the
Subcommand
class from @sapphire/[email protected]
instead of the "normal" Command
one?
I haven't tried it with a "normal" one yet will do that and see if it persistsnah, shouldn't matter
I just tried it and it works as expected with normal commands
When
ApplicationCommandRegistries.setDefaultGuildIds(guildIds);
is set it registers it in the specified guild, and when it is not set it registers it globally, as it should workstrange
Strange indeed.
The registry shouldn't care if it's a subcommand or not
Maybe we have an instanceof... No it extends
I won't have time before then
Here's the uncut command that extends
Subcommand
instead of Command
(doesn't fit on a Discord message):
https://pastebin.com/c8dkpBbs
Just in case I'm accidentally doing something that causes this issuePastebin
import { Subcommand } from '@sapphire/plugin-subcommands';import { ...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
On <t:1710443064>, @Favna asked me to remind you of this:
debug this issue
okay I can definitely confirm this is an issue and only with subcommands @vladdy
apiCalls
just before https://github.com/sapphiredev/framework/blob/main/src/lib/utils/application-commands/ApplicationCommandRegistries.ts#L81 (this is before the global config is read)
Uh
Can you remind me what's the expected result?
@Favna
Also I'm surprised this is happening
the subcommand to register in the guild and not globally
Oh fascinating and yet registerOptions is empty
Does this happen only in bulk overwrite?
no, @Teixeira initially didnt use it
you may want to scroll up to refresh your memory
Oh wait this means something is wrong in the register methods and what they do
I think I see why it happens
Oh?
if the user provides idHints or otherwise an empty object (or other options) then the guildIds dont get set because of
??
https://github.com/sapphiredev/framework/blob/af4115af8e179e9ffb349825901dd2ef88178b63/src/lib/utils/application-commands/ApplicationCommandRegistry.ts#L113-L117Yeah i just checked the code
I guess we just want to spread the options object in our defaulted object
That'll definitely fix it and keep most expected behaviors
That is such a sneaky edge case, I'm genuinely impressed we didn't encounter this sooner
Solution
GitHub
fix: resolved issue with registerOptions not picking up default opt...
Relates to this discord thread
wait
fixed
I mixed up the order of the spread
slow @vladdy
you submitted the review after I already committed the fix
I'm on a phone, sue me
I will
Lets get this out
unlike a certain American I'm not across an ocean
Lmao you're still across borders
Anyways yeah merge and lets release it too
ye
kinda curious if the sonarqube bot is gonna comment on the PR...
I think it should
Yep I can confirm I was using
idHints
Nice catch
doesnt look like it does. Sadge.
Well have fun debugging that too 😂
meh not something that can be debugged. I thought that was a sonarqube feature but I may have just misread the docs
Can you trigger a release too? 💙
So I'll have to wait for the update to be pushed to sapphire and then I can npm update my version and should be good to go?
Yap
Okay thank you both for the help!
But poke us if tye update didn't work
Oh neat yarn supports that too?
I think npm does a callback of sorts because I get that with
npm deprecate
, with yarn npm publish
it gives a token to copy to terminalOne last thing, should I mark any of the messages here as the solution, to @Answer Overflow? Feels like I shouldn't but not sure
probably just the one with the link to the PR
anyway released
After updating the package I'm getting a TS error:
I ran
npm update @sapphire/framework
yeah I know
tsup fucked something up
im looking into it
fixed @Teixeira
Thank you!