This snippet shows you how you can use subcommands for slash command in discord! To set this command up you need to go to the slash command builder (https://autocode.com/tools/discord/command-builder/), link your bot and create a slash command named "subcommand" with two options of subcommand named "first-subcommand-name" and "second--subcommand-name" respectively. (you can change the names if you want)
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
if (context.params.event.data.options[0].name === 'first-subcommand-name') {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: context.params.event.channel_id,
content: `1st Subcommand has been triggered by <@${context.params.event.member.user.id}>!`,
});
} else if (context.params.event.data.options[0].name === 'second-subcommand-name') {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: context.params.event.channel_id,
content: `2nd Subcommand has been triggered by <@${context.params.event.member.user.id}>!`,
});
}