Getting started
If you're new to Sunar, you can follow these steps to get started building your discord bot!
Automatic Installation
Create a new app with create-sunar
, it requires Node.js 18+.
You will be prompted to enter some details about your project, such as the project name, preferred language (TypeScript or JavaScript), and desired features (e.g., Biome, TSX, TSUP, Prettier, ESLint).
Manual Installation
Ensure you have Node.js (18 or newer) installed on your machine. Sunar requires discord.js as a peer dependency.
Initialize the client
Create a new file, e.g., index.js
, and set up your Discord bot using Sunar.
Replace 'YOUR_DISCORD_BOT_TOKEN'
with your actual bot token obtained from
the Discord Developer Portal.
Create your first signal
Signals handle events in your Discord bot. Let's create a basic ready
signal to log when the bot is online and ready.
This basically register all loaded application commands (by default globally). If you want to change this behavior read the registering commands guide.
Create your first command
Let's create a simple ping
command that responds with the bot's ping when invoked.
Handle interactions
To make the ping command work, add the interactionCreate
signal to your project to handle interactions:
For more information about the interaction handling, see handle interactions guide.
File structure
Here's an overview of the project's file structure to help you visualize how files are organized within Sunar.
Next steps
- Customize and expand your commands and signals based on your bot's functionality.
- Dive deeper into command options such as subcommands, options, and permissions to create more complex and versatile interactions.
- Explore comprehensive features like context menu commands, buttons, modals, and more.
Last updated on