How do I create subcommands with different text input fields?

Something like the image. The Docs only show how to create basic subcommands. Also in the Readme of the subcommand plugin it is not mentioned
Solution:
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
25 Replies
chillihero
chillihero2y ago
I implemented it to this point, but now the chatinputs are not there
Favna
Favna2y ago
you still have to register the application commands by following the application registry guide
chillihero
chillihero2y ago
good to know, this is not shown in the readme of the plugin...
chillihero
chillihero2y ago
wait is a chatinput command this?
Solution
chillihero
chillihero2y ago
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
chillihero
chillihero2y ago
Is the only way to create those command registery via the builder?
Favna
Favna2y ago
That is a chat input command yes
Favna
Favna2y ago
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Favna
Favna2y ago
or well the command is birthday the subcommand is register and day is an option
Favna
Favna2y ago
and you can refer to the DJS guide to learn more about commands, as well as above linked Discord docs https://discordjs.guide/creating-your-bot/slash-commands.html
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Favna
Favna2y ago
you can provide a regular object as well but. especially for someone like you whose new to this I very strongly recommend using the builder because you're not yet familiar with all the syntax. Using a builder will also give you runtime code validation.
chillihero
chillihero2y ago
do you have resources where I can find out more about working with regular objects? Im migrating my bot from the old plattform i was using (Autocode) and have the objects for the commands already. Just out of curiosity
{
"name": "birthday",
"description": "Birthday Command",
"options": [
{
"type": 1,
"name": "register",
"description": "Register your Birthday",
"options": [
{
"type": 4,
"name": "day",
"description": "Day of birthday",
"required": true
},
{
"type": 3,
"name": "month",
"description": "Month of birthday",
"choices": [
{
"name": "January",
"value": "01"
},
{
"name": "February",
"value": "02"
},
{
"name": "March",
"value": "03"
},
{
"name": "April",
"value": "04"
},
{
"name": "May",
"value": "05"
},
{
"name": "June",
"value": "06"
},
{
"name": "July",
"value": "07"
},
{
"name": "August",
"value": "08"
},
{
"name": "September",
"value": "09"
},
{
"name": "October",
"value": "10"
},
{
"name": "November",
"value": "11"
},
{
"name": "December",
"value": "12"
}
],
"required": true
},
{
"type": 4,
"name": "year",
"description": "Year of birthday"
},
{
"type": 6,
"name": "user",
"description": "Set a birthday for another Person - MANAGER ONLY"
}
]
},
{
"type": 1,
"name": "list",
"description": "List all Birthdays in this Discord server"
},
{
"type": 1,
"name": "remove",
"description": "Remove a birthday - MANAGER ONLY",
"options": [
{
"type": 6,
"name": "user",
"description": "The user you want to remove the birthday from",
"required": true
}
]
},
{
"type": 1,
"name": "show",
"description": "Show the Birthday of you or a other person",
"options": [
{
"type": 6,
"name": "user",
"description": "Show the birthday of a specific User"
}
]
},
{
"type": 1,
"name": "test",
"description": "Test your current birthday configurations"
}
]
}
{
"name": "birthday",
"description": "Birthday Command",
"options": [
{
"type": 1,
"name": "register",
"description": "Register your Birthday",
"options": [
{
"type": 4,
"name": "day",
"description": "Day of birthday",
"required": true
},
{
"type": 3,
"name": "month",
"description": "Month of birthday",
"choices": [
{
"name": "January",
"value": "01"
},
{
"name": "February",
"value": "02"
},
{
"name": "March",
"value": "03"
},
{
"name": "April",
"value": "04"
},
{
"name": "May",
"value": "05"
},
{
"name": "June",
"value": "06"
},
{
"name": "July",
"value": "07"
},
{
"name": "August",
"value": "08"
},
{
"name": "September",
"value": "09"
},
{
"name": "October",
"value": "10"
},
{
"name": "November",
"value": "11"
},
{
"name": "December",
"value": "12"
}
],
"required": true
},
{
"type": 4,
"name": "year",
"description": "Year of birthday"
},
{
"type": 6,
"name": "user",
"description": "Set a birthday for another Person - MANAGER ONLY"
}
]
},
{
"type": 1,
"name": "list",
"description": "List all Birthdays in this Discord server"
},
{
"type": 1,
"name": "remove",
"description": "Remove a birthday - MANAGER ONLY",
"options": [
{
"type": 6,
"name": "user",
"description": "The user you want to remove the birthday from",
"required": true
}
]
},
{
"type": 1,
"name": "show",
"description": "Show the Birthday of you or a other person",
"options": [
{
"type": 6,
"name": "user",
"description": "Show the birthday of a specific User"
}
]
},
{
"type": 1,
"name": "test",
"description": "Test your current birthday configurations"
}
]
}
mine look like this
Favna
Favna2y ago
that exactly
registry.registerChatInputCommand({
name: 'birthday',
description: 'Birthday Command',
options: [
{
type: 1,
name: 'register',
description: 'Register your Birthday',
options: [
{
type: 4,
name: 'day',
description: 'Day of birthday',
required: true
},
{
type: 3,
name: 'month',
description: 'Month of birthday',
choices: [
{
name: 'January',
value: '01'
},
{
name: 'February',
value: '02'
},
{
name: 'March',
value: '03'
},
{
name: 'April',
value: '04'
},
{
name: 'May',
value: '05'
},
{
name: 'June',
value: '06'
},
{
name: 'July',
value: '07'
},
{
name: 'August',
value: '08'
},
{
name: 'September',
value: '09'
},
{
name: 'October',
value: '10'
},
{
name: 'November',
value: '11'
},
{
name: 'December',
value: '12'
}
],
required: true
},
{
type: 4,
name: 'year',
description: 'Year of birthday'
},
{
type: 6,
name: 'user',
description: 'Set a birthday for another Person - MANAGER ONLY'
}
]
},
{
type: 1,
name: 'list',
description: 'List all Birthdays in this Discord server'
},
{
type: 1,
name: 'remove',
description: 'Remove a birthday - MANAGER ONLY',
options: [
{
type: 6,
name: 'user',
description: 'The user you want to remove the birthday from',
required: true
}
]
},
{
type: 1,
name: 'show',
description: 'Show the Birthday of you or a other person',
options: [
{
type: 6,
name: 'user',
description: 'Show the birthday of a specific User'
}
]
},
{
type: 1,
name: 'test',
description: 'Test your current birthday configurations'
}
]
});
registry.registerChatInputCommand({
name: 'birthday',
description: 'Birthday Command',
options: [
{
type: 1,
name: 'register',
description: 'Register your Birthday',
options: [
{
type: 4,
name: 'day',
description: 'Day of birthday',
required: true
},
{
type: 3,
name: 'month',
description: 'Month of birthday',
choices: [
{
name: 'January',
value: '01'
},
{
name: 'February',
value: '02'
},
{
name: 'March',
value: '03'
},
{
name: 'April',
value: '04'
},
{
name: 'May',
value: '05'
},
{
name: 'June',
value: '06'
},
{
name: 'July',
value: '07'
},
{
name: 'August',
value: '08'
},
{
name: 'September',
value: '09'
},
{
name: 'October',
value: '10'
},
{
name: 'November',
value: '11'
},
{
name: 'December',
value: '12'
}
],
required: true
},
{
type: 4,
name: 'year',
description: 'Year of birthday'
},
{
type: 6,
name: 'user',
description: 'Set a birthday for another Person - MANAGER ONLY'
}
]
},
{
type: 1,
name: 'list',
description: 'List all Birthdays in this Discord server'
},
{
type: 1,
name: 'remove',
description: 'Remove a birthday - MANAGER ONLY',
options: [
{
type: 6,
name: 'user',
description: 'The user you want to remove the birthday from',
required: true
}
]
},
{
type: 1,
name: 'show',
description: 'Show the Birthday of you or a other person',
options: [
{
type: 6,
name: 'user',
description: 'Show the birthday of a specific User'
}
]
},
{
type: 1,
name: 'test',
description: 'Test your current birthday configurations'
}
]
});
specifically
chillihero
chillihero2y ago
ohh hats easy id prefer it like this then
Favna
Favna2y ago
you do you but I personally never liked the vagueness of type. It's a magic number. It doesn't what type it is at all.
chillihero
chillihero2y ago
i see what you mean
Favna
Favna2y ago
You either have to remember what type is what, or constantly reference it whereas with builders you have things like addStringOption
chillihero
chillihero2y ago
a more unrelated question, cant I use this.description to reference the description I wrote in the ApplyOptions?
Favna
Favna2y ago
no
chillihero
chillihero2y ago
So I need to write the description twice in the file
Favna
Favna2y ago
also you shouldnt have a constructor and @ApplyOptions I read it as "can I use" not "cant I use" lol look at some examples tbh
Spinel
Spinel2y ago
__Discord bots that use @sapphire/framework v4 - Official Bot Examples ᴱ ᴰ ᴶˢ - Dragonite ᴱ ᴰ __Discord bots that use @sapphire/framework v3 - Archangel ᴱ ᴰ - Arima ᴱ - Nino ᴱ ᴰ - Operator ᴱ ᴬ ᴰ - Radon ᴱ ᴬ - Sapphire Application Commands Examples ᴱ - Spectera ᴬ Discord bots that use @sapphire/framework v2 - Materia ᴱ - RTByte ᴱ ᴬ - Skyra ᴬ ᴰ - YliasDiscordBot ᴬ : Uses ESM (if not specified then uses CJS) : Advanced bot (if not specified it is a simple bot, or not graded) : Uses Docker in production ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
Krish
Krish2y ago
broken markdown syntax yay
Favna
Favna2y ago
yeah I just fixed it
Krish
Krish2y ago
RIP my PR to sapphiredev/sapphire-slashies
Want results from more Discord servers?
Add your server