Skip to content

gonepecan/Synapse-Base

Repository files navigation

Synapse V5

Overview

Synapse V5 is a modular, extensible, and highly customizable Discord bot and dashboard system designed for advanced users and developers who want full control over bot commands, event handling, dashboard management, and data persistence.


Table of Contents


Features

Advanced Command System

  • Hot-reloadable commands with automatic state tracking
  • Command aliases support
  • Granular permission controls
  • Cooldown management
  • Guild-only and owner-only restrictions
  • Command categories

Interactive Dashboard

  • Real-time command management
  • Live command enabling/disabling
  • Command settings modification
  • Search and filtering
  • Command statistics

Robust Event System

  • Custom event listeners
  • Interaction handling (Buttons, Menus, Modals)
  • Error tracking and reporting

Security & Database

  • SQLite with prepared statements
  • Permission validation
  • Settings management

Development Tools

  • Hot Module Reloading
  • Template generation for rapid development
  • Detailed logging system
  • Environment validation

Installation

Prerequisites

  • Node.js v18+
  • npm (comes with Node.js)
  • Discord Bot Token

Setup Steps

Important: Before anything, run npm init in the console and spam through the prompts.

  1. Start the setup process:

    node .
  2. Follow the prompts:

    • Enter prefix: Common prefix is !
    • Enter dashboardPort: Typical port is 3000
    • Enter bot token: Your Discord bot token
    • Enter package manager: Common is npm
  3. Access your dashboard: After setup, Ctrl+LeftClick the https://localhost:yourport link


Directory Structure

synapse-v5/
├── config.json
├── index.js
├── package.json
├── backups/
├── commands/          # Bot commands by category
├── components/        # UI components (buttons, menus, modals)
├── dashboard/         # Web dashboard server and assets
├── events/           # Discord event listeners
├── prefix/           # Command prefix configuration
└── utils/            # Core utilities and helpers

Creating Commands

Commands are automatically generated using the TemplateGen utility. Place command files in the commands/ directory organized by category.

Command Structure

module.exports = {
    data: new SlashCommandBuilder()
        .setName('command')
        .setDescription('Command description'),
    category: 'Category',
    cooldown: 5,                    // seconds
    guildOnly: true,               // server only command
    devOnly: false,                // developer only command
    permission: 'MANAGE_MESSAGES', // required permission, supports both V13 and V14 syntax
    alias: ['cmd', 'cm'],          // command aliases
    execute: async (interaction) => {
        // Command logic
    }
};

Command Features

  • Hot Reloading: Modify and reload without restarting
  • State Tracking: Changes tracked using CRC32 hashing
  • Aliases: Multiple names for the same command
  • Restrictions: Guild-only, owner-only, permission-based access
  • Cooldowns: Per-command and global management
  • Categories: Organize by function/purpose

Creating Events

Events are automatically generated using the TemplateGen utility. The template generator will create the basic structure for you.

Event Structure

const db = require('../../dashboard/server/database/DB');
const { ChannelType } = require('discord.js');

module.exports = {
    event: "eventName",
    once: false,
    
    async execute(message, client) {
    }
};

Template Generated Events

The TemplateGen utility automatically generates event templates:

module.exports = {
    name: '${name}',
    once: false,
    
    async execute(client, ...args) {
        client.logs.event(`${name} event fired`);
    }
};

Event Properties

  • event/name: The Discord.js event name
  • once: Whether the event should only fire once
  • execute: The function that runs when the event is triggered

Creating Components

Components handle UI interactions like buttons, select menus, and modals. The TemplateGen utility automatically generates component templates.

Component Structure

module.exports = {
    customId: 'componentid',
    async execute(interaction, client) {
        await interaction.reply('Component activated!');
    }
};

Component Types

  • Buttons: Interactive buttons in messages
  • Select Menus: Dropdown selection menus
  • Modals: Pop-up forms for user input

Template Generation

The TemplateGen utility creates these components automatically with proper structure and error handling.


Dashboard

The dashboard provides a comprehensive web interface for bot management.

Features

Command Management:

  • Real-time command toggling
  • Settings modification
  • Command reloading
  • Category filtering
  • Search functionality
  • Statistics tracking

Interface:

  • Modern, responsive design
  • Dark theme
  • Interactive modals
  • Toast notifications
  • Loading indicators

API Endpoints:

  • /api/commands/:name/settings - Update command settings
  • /api/commands/:path/reload - Reload specific commands
  • /api/commands/refresh - Refresh all commands
  • /api/shutdown - Graceful shutdown

Database

  • SQLite database at dashboard/server/database/dashboard.db
  • Schema in dashboard/server/database/dashboard.sql
  • Access via DB.js utility
  • Prepared statements for security and performance

Development Tools

Template Generation

The TemplateGen utility (utils/TemplateGen.js) automatically generates:

  • Command templates with proper structure
  • Event listeners with error handling
  • Component handlers with interaction logic
  • Database schemas and utilities

Hot Reloading

  • HotReloader for live updates without restarts
  • Command hash tracking for change detection
  • State persistence across reloads

Logging System

  • Detailed logging with multiple levels
  • Error tracking with unique IDs
  • Color-coded console output
  • File logging for persistence

Backup & Restore

Backups include:

  • Configuration files
  • Database
  • Custom commands and events
  • Dashboard settings

Troubleshooting

Common Issues

Bot not starting:

  • Verify bot token in config.json
  • Check Node.js version (v18+ required)

Dashboard not loading:

  • Ensure port is available
  • Check firewall settings
  • Verify dependencies installed

Database errors:

  • Check SQLite file permissions
  • Verify schema integrity
  • Ensure database directory exists

Debugging Tools

  • Console logs with detailed error information
  • Environment checks via EnvironmentCheck.js
  • Package validation via PackageChecker.js
  • Intent verification via IntentChecker.js

Credits

-- Developed by Ghost!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published