Skip to content

auth-xyz/Cerebrum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


logo


Cerebrum

"Cerebrum", Latin for "Brain", is an idea I had a long time ago, where I thought, "What if there was a bot, where the server owner had total access to add or remove commands and events with a simpler structure?", so this is basically that this project is. It's a modular discord bot, you can write your own events and commands in a far simpler structure than the usual discord.js, and in the near future (I hope), it will support TypeScript and normal JS (as it's built with mjs)


  • Why? Well the whole reason for this project, was a silly idea I had and wanted to put it in practice.
  • How is it better? To be completely honest, it depends pretty much on who uses the bot, since it's going to be modular, I want to make some internal nodes (events,commands), but those will only be available if the server owner allows them.
  • How does it work? At its current state, you'd code a basic event or command, write a node_config.json, the config node will parse the config, send it to the sorter node, which then will be sent to the loader and finally, it'll be reloaded and executed by the "Cerebrum" (the main node). In a future iteration, I want it to be able to: Detect malicious code, as well as have its own framework for making event creation and command creation made easier, so that even someone who knows nothing of javascript can make their own command and/or event.

Now, for how to set the code up: You'll obviously need nodejs installed, as well as your preferred tool for installing/managing your dependencies. I personally used pnpm, but it's really based on preference.

git clone https://github.com/auth-xyz/Cerebrum

After cloning the repo, cd into it and run pnpm i

cd Cerebrum
pnpm install # or pnpm i, same thing.

And since the bot isn't ready for you know, the whole being one bot thing, you'll need to make a .env file for the bot to actually work. Your .env file should look like this:

DISCORD_TOKEN=yourbottokenhere
CLIENT_ID=yourbotcientidhere

After all of that, you may be disappointed to know that the code won't run, because you need a node for it to actually run. (ps: the code will actually work since the repository currently includes internal nodes that I haven't put inside a proper repository, but we don't talk about that...)

So, now for a node creation, pretty simple stuff. A node, in basic terms, is just the commands and events for a discord.js bot, I'm sure if you're reading until here you know how to make one of those, the code will handle both events and commands. You'll make a directory inside nodes/ with whatever name you want, then you'll make a file called node_config.json, inside this file it'll be the specifications of your code, as well as paths for the commands and events. Your node config should look like this:

{
	"name": "example node",
	"author": "auth-xyz",
	"description": "your node description",
	
	"node_version": "1.0",
	"node_guildid" : "1234567890",
	"node_type": "server", // hybrid (both global and server), internal, server
	"node_commands": [
		"/path/to/command1.js",
		"/path/to/command2.js"
	],
	"node_events": [
		"/path/to/event1.js",
		"/path/to/event2.js"
	]
}

For the internal folder inside nodes, you may see that this is it's structure:

nodes/internal/
├── events
│   ├── interactionCreate.js
│   ├── messageCreate.js
│   └── ready.js
└── node_config.json

2 directories, 4 files

Inside the node_config.json, you'll see that it only has events. The config may not have commands, but it still works. SO that logic also works for commands, so essentially, a server owner could make a command which needs the interactionCreate event (which the bot provides internally), and the code would load that command with no issue.

About

something something brain something something

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published