Welcome to the Juniper Nexus Discord Bot repository! This bot is designed to enhance the functionality of the Juniper Nexus guild on Discord.
- Pre-configured Linting and Formatting: Includes ESLint and Prettier configurations for consistent code style.
- Pre-commit and Pre-push Hooks: Uses Husky to enforce code quality before committing and pushing changes.
- Environment Configuration: Uses
dotenv
andzod
for environment variable management and validation. - Structured Command and Event Handling: Easily add new commands and events with a modular structure.
- Error Handling: Comprehensive error handling for commands and events.
To get started with the Juniper Nexus Discord Bot, follow these steps:
-
Clone the repository:
git clone https://github.com/JuniperNexus/discord-bot.git cd discord-bot
-
Install dependencies:
npm install
-
Build the project:
npm run build
Create a .env
file in the root directory of the project or copy the example .env.example
and add your Discord bot token and other necessary configurations:
cp .env.example .env
Edit the .env
file with the following values:
# Discord Bot Token
# https://discord.com/developers/applications
TOKEN=
# Discord Bot Client ID
# https://discord.com/developers/applications
CLIENT_ID=
# Discord Guild ID
# https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-
GUILD_ID=
# Discord User ID of the bot owner
# https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-
OWNER_ID=
# Discord Role ID for Juniper Nexus members
MEMBER_ROLE_ID=
# Discord Role ID for people interested in the Juniper Nexus
INTERESTED_ROLE_ID=
# Connect to Supabase via connection pooling with Supavisor.
DATABASE_URL=
# Direct connection to the database. Used for migrations.
DIRECT_URL=
For development with live reloading:
npm run dev
To run the bot in production with PM2:
-
Install PM2 globally (if not already installed):
npm install -g pm2
-
Start the bot using PM2:
pm2 start dist/index.js --name "discord-bot"
-
Save PM2 Configuration:
pm2 save pm2 startup
-
To manage the bot process (restart, stop, view logs):
pm2 restart discord-bot pm2 stop discord-bot pm2 logs discord-bot
To run the bot in production with Docker:
-
Build and Start the Services:
docker compose up --build -d
-
Stopping the Services:
docker compose down
We welcome contributions! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch with your feature or bugfix.
- Ensure your code follows the linting and formatting guidelines.
- Commit your changes with a descriptive message.
- Push your branch and create a pull request.
This project uses Husky to run pre-commit and pre-push hooks. Ensure your changes pass all checks by running:
npm run lint
npm run format:fix
This project is licensed under the MIT License. See the LICENSE file for details.