#How to designate between Guild and Global Slash Commands in IF?

1 messages · Page 1 of 1 (latest)

tacit osprey
#

Using IF, how do I tell the library that a Slash Command is intended for a specific guild vs meant to be global? I understand that I can register commands via RegisterCommands*Async, but how would they determine a command meant for a guild over a command meant for global publication? (Currently, I'm just publishing to a dev guild for the faster refresh, but I have a test I want to do in DM's, but guild commands can't be used in DM).

tacit osprey
#

Unrelated bonus question: According to discord docs, you can use </NAME SUBCOMMAND_GROUP SUBCOMMAND:ID> syntax to hyperlink a slash command -- is the ID of each slash command in IF stored in Context.Interaction.Id, or is that just the Id of the current interaction?

random coyote
#

That's the id of interaction

random coyote
tacit osprey
#

Even still, is there a way to differentiate which slash command is supposed to be global versus guild-level ? End result will have mostly global, but a few guild-level commands that are custom tailored.

random coyote
#

I believe that's not possible

#

Yup, discord does not send you anything that could determine what kind of command was used

tacit osprey
#

I meant is there like an attribute or a way to filter the commands registered from the interaction service to control which is registered globally versus a guild

random coyote
#

ah
there's a DontAutoRegister attribute

#

add it to module that is meant to be for guild commands

#

and then register the module with InteractionService.AddModulesToGuildAsync

tacit osprey
#

you the best thatviGoat

tacit osprey
# random coyote That's the id of interaction

regarding this part, do you know where the discord-sided ID of a slash command is stored, or how to retrieve said info ? Do I have to make a separate call to pull this info back or does DNet cache this when registering commands ?

random coyote
#

iirc d.net doesn't cache app commands

#

but

#

yup, InteractionService.RegisterCommands...Async & AddModulesToGuildAsync return a collection of RestGuildCommand

#

which have .Id property

#

so you could cache ids after registering commands
or

#

call DiscordsocketClient.Rest.GetXApplicationCommands
X being either Guild or Global

#

it returns same collection of rest guild commands which have the id