nexcord-hello
v0.0.1Example Nexcord slash command that registers /hello and replies with an ephemeral greeting — a good starting point for building your own commands.
xnex install nexcord-hello GitHub repo Nexcord Hello Recipe
A minimal starter recipe that adds a single /hello slash command to a Nexcord bot. Use it as a template for new commands, or as a quick check that command registration and interaction handling are wired up correctly.
Files
| File | Installed to |
|---|---|
src/commands/hello.command.ts | src/commands/ |
recipes/nexcord-hello/README.md | recipes/nexcord-hello/ |
This mapping comes from recipe.json, which Nexcord's recipe tooling reads to know where to copy each file.
Requirements
@nexcord/core— providesBaseSlashCommandand the@SlashCommanddecoratordiscord.js^14.26.4reflect-metadata— needed for Nexcord's decorator metadata; import it once near your bot's entry point- TypeScript ^6.0.3, with
experimentalDecorators(andemitDecoratorMetadata) enabled intsconfig.json
How it works
@SlashCommand('hello', 'hello command')
class HelloCommand implements BaseSlashCommand {
build(b: SlashCommandBuilder) {
return b
}
handler(i: CommandInteraction): void | Promise<void> {
i.reply({ content: 'Hello!!', flags: 'Ephemeral' })
}
}
@SlashCommand('hello', 'hello command')registers the command's name and description with Nexcord.build(b)receives theSlashCommandBuilderNexcord already configured from that name/description, and returns it unchanged — no extra options, subcommands, or permissions are added.handler(i)runs when someone uses/hello. It replies withHello!!as an ephemeral message, so only the user who ran the command can see it.
Usage
- Copy the recipe's files to the destinations listed above (or apply the recipe with your project's tooling, if you have a recipe installer set up).
- Make sure
hello.command.tsends up wherever Nexcord scans for commands (src/commands). - Start the bot:bash
bun run bot - In a server the bot is in, run
/hello— you'll get back a privateHello!!reply.
Customizing
- Change the reply text — edit the string passed to
i.reply(...). - Make the reply public — remove the
flags: 'Ephemeral'option. - Add options or subcommands — extend
build(b)with.addStringOption(),.addSubcommand(), etc. before returningb. - Rename the command — change the first argument of
@SlashCommand(...), and keep the file/class name in sync for readability.
Versions
Release links are tracked by Nex; source code lives in the developer's GitHub repo.
setup.files
Files that will be integrated into your project
- recipes
- nexcord-hello
- README.md → recipes/nexcord-hello
-
-
- src
- commands
- hello.command.ts → src/commands
-
-
nexconfig
Full recipe configuration
{
"name": "nexcord-hello",
"version": "0.0.1",
"description": "Example Nexcord slash command that registers /hello and replies with an ephemeral greeting — a good starting point for building your own commands.",
"keywords": [
"nex",
"recipe",
"nexcord",
"discord",
"discord.js",
"slash-command",
"hello-world",
"example",
"typescript"
],
"files": [
"src/commands/hello.command.ts",
"recipes/nexcord-hello/README.md"
],
"setup": {
"scripts": [],
"files": {
"src/commands/hello.command.ts": "src/commands",
"recipes/nexcord-hello/README.md": "recipes/nexcord-hello"
}
}
}
You might also be interested in these
nexcord-log
Discord bot Message & Voice log bot recipe
nexcord-core
Nexcord basic project recipe
nestjs-basic-auth
NESTJS BASIC AUTH RECIPE
nestjs
NESTJS EMPTY TEMPLATE
nestjs-logging
NESTJS REQUEST LOGGING MIDDLEWARE RECIPE