Sunar

Load modules

Modules in Sunar encapsulate related commands, signals and components, enabling efficient organization and management of your bot's capabilities. Learn how to leverage Sunar's modular architecture to streamline development and scalability.

Example

All you have to do is use the load function and use a glob pattern:

src/index.js
import { Client, load } from 'sunar';
 
const client = new Client(/* your options */);
 
const start = async () => {
	// you can add more directories to load by
	// passing them with a comma after "signals"
	await load('src/{commands,signals}/**/*.{js,ts}'); 
 
	return client.login('YOUR_DISCORD_BOT_TOKEN');
};
 
start();

Replace 'YOUR_DISCORD_BOT_TOKEN' with your actual bot token obtained from the Discord Developer Portal.

If you are using ECMAScript modules, you can use the top-level await feature and avoid the start function.

File structure

Here's an overview of the project's file structure to help you visualize how files are organized within Sunar.

ping.js
interaction-create.js
ready.js
index.js

Last updated on

On this page

GitHubEdit on Github ↗