Subcommand in Direct Messages even with guildIds option
I have
{ guildIds: [this.container.config.guildId] }
in my subcommand registry, but I still can see command in direct messages with that bot21 Replies
Might just be client cache but if you want to be absolutely sure use the discordjs methods for managing application commands to check if it's there or not
Okay so... I have like 5 bots, and some of them has some commands that registered globally. Tried to remove all I even tried to delete this commands using d.js and info from that doc about commands being stored and not removed after created. Anyway same result, they registreting to global list. I will try to reinstall node_modules, maybe that an issue with cache or something else at the deeper lvl... And if that will not solve the issue - i have 0 ideas why this could happening
Will stick to that solution for now 👍 But it feels like that an very bad solution...
applicationCommands
for one of them just to see if it will solve the issue. But no, when I restarted bot command still was registering to global list even with specified guildId
. I looked up at setup
file that I call for registering plugins and found that:
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.Overwrite)
. Changed to just Overwrite, but still commans remain in global list and even some old commands that no longer included in bot (they was literally deleted from files) are here, wtf :/
using ApplicationCommandRegistries.setDefaultGuildIds
and RegisterBehavior.BulkOverwrite
worked fine. Global commands were removed, and old commands that don't even exist too. But I have command for example /ticket
that should be available globaly. I wonder why sapphire registers some commands to global list even with provided guildIds
property on them
Like why ApplicationCommandRegistries.setDefaultGuildIds
worked, but
this code dont
I found out that commands have .setContexts()
method. It worked! Commands are no longer visible in dms if I set it to Guild
. But anyway, sapphire still register them as global commands, very weird why it's registering globally at all with provided guildIds
uhm, theres no way for that code to not have made the cmd just on the guild..
can you get us a minimum repro sample pls
in a repo
Writing from my main acc.
Currently working on creating repro sample. I read in #cant declare container items that you need to include some stuff in
.npmrc
config for sapphire to work properly when using pnpm
. On my main repo I don't get those errors about packages not found when declaring stuff. But now when I'm creating sample I got one error. Could it be potential problem why commands registering weird? :hmmm:
Done! Repo: https://github.com/shysecre/test-sample-sapphire
1. Clone. pnpm install
in main directory. pnpm
because I use workspaces by pnpm. I dont know if other package managers will work :Shruge:
2. Fill in dev config in config/dev.json
with tokens & guild id
3. Maybe check out redis settings if they will overlap with yours. I use docker-compose
4. pnpm build
, pnpm start:devmod
Also I have a .tasks
for vscode so you can easily start "watch" for all packages. Ctrl + Shift + P
-> Run Tasks
-> watch:all
and then if restart is needed pnpm start:devmod
I guess that's all :eeeh: Also I removed .setContexts
for commands in yume-bot
. And this commands still registering globally.
setup
function can be found in packages/common/src/util/setup.ts
In packages
folder I also have sapphire-utilities stuff where I register shared preconditions, listeners, utilities among all bots. I dont think that will somehow effect commands, but yeahWhat is the config module exactly
I can't see it in pkg.jsons nor defined otherwise
Can you print your config that's loaded and ensure the guild id is correctly there
It's loading tokens so I guess guildId works too... But yeah sure, give me a sec
yea config loads correctly
Interesting
And you're using bulkOverwrite correct?
what is that pnpm version, it does not exist at all
your repro can't even start bc of config
might be a local issue, not sure
aha
NODE_ENV=dev node ./apps/economy-bot/build/index.js
this sees no cmds :CLk_Kekega:
okNODE_ENV=dev NODE_CONFIG_DIR=../../config node ./build/index.js
bleh
ok
CNR tho
not with economy at least
your event-bot has no guild ids
bc of syntax errors
baited by comma operator
ticket doesn't have it at all
same syntax issues in yume
you could/should also use defaultGuildIds for this so you don't forget itit's kinda interesting because I created snippet for commands at the start and used it for all others. I wanna check if others commands have the same issue
I can't because sometimes I need commands that users can use in dms too. As ticket command (i don't know why I even include it in repro sample, my bad)
well, regardless, main issue is you have comma operator issues
I see yes. And it also occurs in my snipper. I probably should fix that in all commands :||| I wonder why TS gives no error about this comma
because its valid syntax
and is used a lot in bundlers too when shrinking code
eslint would've probably caught that tho
probably will add lint to project, would be great in the distance to not make stupid mistakes like this :derp:
thanks for help and your time I guess. Pretty awkward to ask someone to help and found out that issue was because of a single comma :WAHHHHHHHHHHHHH:
yeahhh, been there done that
dw