- Music: Play and manage music in your Discord server using Erela.js with Spotify integration.
- Moderation: Tools for server moderation.
- Information Commands: Access various information commands, including FFXIV Lodestone character data.
- Logging: Centralized logging system using Consola for better debugging and monitoring.
- Error Handling: Robust error handling using Effect.
- Hot Reloading: Automatic reloading of commands and events during development.
Terra is a Discord bot written in TypeScript using the Eris library for Discord bot functionality. It features a modular command system, event handling, and integration with external APIs like FFXIV Lodestone.
- Server: Node.js, Bun, Eris
- Music: Erela.js with Spotify integration
- Logging: Consola
- Error Handling: Effect
- File Scanning: Globby
- Hot Reloading: Chokidar, perfect-debounce
-
Install Bun:
For macOS and Linux:
curl -fsSL https://bun.sh/install | bash
For Windows:
powershell -c "irm bun.sh/install.ps1|iex"
Note: Bun requires a minimum of Windows 10 version 1809.
-
Verify the installation:
bun --version
-
Clone the repository:
git clone https://github.com/pieckenst/terra.git cd terra
-
Install dependencies:
bun install
-
Set up your environment variables in a .env file:
token=YOUR_DISCORD_BOT_TOKEN
-
Create a config.json file in the root directory with the following structure:
{
"prefix": "!",
"dirs": {
"commands": "./commands",
"events": "./events"
},
"debug": true,
"clientID": "YOUR_SPOTIFY_CLIENT_ID",
"clientSecret": "YOUR_SPOTIFY_CLIENT_SECRET",
"host": "localhost",
"port": 2333,
"password": "youshallnotpass",
"ownerId": "YOUR_DISCORD_USER_ID"
}
We recommend using bun package manager to launch this TypeScript project. To start the bot, run:
bun run core.ts
Command examples:
!lodestone Cerberus Zenos yae Galvus
: This command fetches FFXIV character information from Lodestone..!ban [user]
: Bans a user from the server.
The core file initializes the bot and sets up command and event handling:
async function main() {
const harmonix = await initHarmonix();
await loadCommands(harmonix);
await loadEvents(harmonix);
// ... (event listeners and error handling)
}
Terra uses a flexible command structure defined in src/code-utils/definingcommand.ts. Here's how to create a command:
import { defineCommand } from '../code-utils/definingcommand';
export default class extends defineCommand({
name: "commandname",
description: "Command description",
usage: "commandname <arg>",
category: "Category",
aliases: [],
slashCommand: true,
options: [], // For slash command options
permissions: ['SEND_MESSAGES'],
ownerOnly: false,
}) {
static async execute(harmonix, message, args) {
// Command logic here
}
}
This structure allows for easy creation of both regular and slash commands, with built-in permission checks and owner-only restrictions.
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or fix.
- Submit a pull request describing your changes.
To run this project, you will need to add the following environment variables to your .env file
token
- Your Discord bot token
If you have any feedback, please reach out in the discord server https://discord.com/invite/XjKfPTa5Kq