idhint & command id

Is sapphire framework supposed to assign command id to every command whether it is global or guild-only? also, can we put idHints directly in the slash commands or not? if not, what do you suggest
Solution:
first question is a yes because that's just how the Discord API works (as well as databases in general for that matter). Every entity has an id. A message (like this), a user, a guild (server), channel, thread, forum post, etc, they all have ids. For your second question, I'm not exactly sure what you're asking. There is only 1 valid place to put the idHints and that's as part of the registerChatInputCommand / registerContextMenuCommand function's second paramater (options) ```ts public override registerApplicationCommands(registry: Command.Registry) {...
Sapphire Framework
Registering Chat Input Commands | Sapphire
To register a Chat Input Command (also known as a Slash Command) with Discord, you need to acquire an application
Jump to solution
4 Replies
Solution
Favna
Favna•4mo ago
first question is a yes because that's just how the Discord API works (as well as databases in general for that matter). Every entity has an id. A message (like this), a user, a guild (server), channel, thread, forum post, etc, they all have ids. For your second question, I'm not exactly sure what you're asking. There is only 1 valid place to put the idHints and that's as part of the registerChatInputCommand / registerContextMenuCommand function's second paramater (options)
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option //
.setName('user')
.setDescription('User to say hello to')
.setRequired(true)
)
, { idHints: ['they go here'] });
}
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option //
.setName('user')
.setDescription('User to say hello to')
.setRequired(true)
)
, { idHints: ['they go here'] });
}
See also: https://sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/registering-chat-input-commands/#idhints
Sapphire Framework
Registering Chat Input Commands | Sapphire
To register a Chat Input Command (also known as a Slash Command) with Discord, you need to acquire an application
Shrewd 💫
Shrewd 💫•4mo ago
registerApplicationCommands(registry) {
registry.registerChatInputCommand(
new SlashCommandBuilder()
.setName(this.name)
.setDescription(this.description)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
{
guildIds: [config.main], // Assuming you want to register this in the main guild
idHints: ['somenumbers'] // Add the command ID here
}
);
}
registerApplicationCommands(registry) {
registry.registerChatInputCommand(
new SlashCommandBuilder()
.setName(this.name)
.setDescription(this.description)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
{
guildIds: [config.main], // Assuming you want to register this in the main guild
idHints: ['somenumbers'] // Add the command ID here
}
);
}
This is how I had it I asked for a little help of my friend to guide me there which obviously was ai
Favna
Favna•4mo ago
at a glance that looks correct. What's the problem you're having, if any? Please show errors and such.
Shrewd 💫
Shrewd 💫•4mo ago
Yeah there is no error, I was just making sure it is all correct and how it is supposed to be because I kept having some trouble understanding certain things in the documentation But if you claim it is correct then thank you very much
Want results from more Discord servers?
Add your server