Craig Discord Recorder Documentation
repository·master·Indexed 19 days ago
https://github.com/craigchat/craigDocumentation for Craig, a multi-track voice recorder for Discord that enables high-quality audio capture from voice channels. Includes guides on self-hosting, configuring the bot via JavaScript objects (covering Redis, sharding, and Discord connection via dexare), managing reward tiers, and using slash commands such as /join, /autorecord, /features, and /info.
What's inside Craig
- Craig is a multi-track voice recorder designed for Discord. It allows users to record audio from Discord voice channels across multiple tracks.
Install Craig using Docker
masterIf you prefer using Docker, ensure Docker is running on your host machine, then build the image from the main repository directory:
docker build -t craig .Note: If using Docker, you must update the
DATABASE_URLin yourinstall.configto use the Docker network bridge format:DATABASE_URL="postgresql://$POSTGRESQL_USER:$POSTGRESQL_PASSWORD@db:5432/$DATABASE_NAME?schema=public"Discord Bot Setup Guide
masterTo connect your Craig instance to Discord, you must create a Discord Bot application and collect the following credentials:
- Application ID: Found under
SETTINGS -> General Information. Maps toDISCORD_APP_IDininstall.config. - Bot Token: Found under
SETTINGS -> Bot. Maps toDISCORD_BOT_TOKENininstall.config. - Client ID: Found under
SETTINGS -> OAuth2 -> General. Maps toCLIENT_IDininstall.config. - Client Secret: Found under
SETTINGS -> OAuth2 -> General. Maps toCLIENT_SECRETininstall.config.
Required Redirect URI: In the Discord Developer Portal, navigate to
SETTINGS -> OAuth2 -> General, click Add Redirect, and paste:http://localhost:3000/api/loginOptional Development Guild: To test experimental slash commands in a specific server without affecting all servers, set the
DEVELOPMENT_GUILD_IDininstall.configand runyarn run sync:dev.- Application ID: Found under
Invite Craig to a Discord server
masterOnce your instance is running, you can invite the bot to your server by constructing an OAuth2 URL. Replace
CLIENT_IDwith your actual Discord Bot Client ID:https://discord.com/oauth2/authorize?client_id=CLIENT_ID&permissions=68176896&scope=bot%20applications.commandsInstall Craig on Linux
masterTo install Craig on a fresh Linux installation (tested on Ubuntu 22.04 and Kubuntu 23.10), follow these steps:
- Clone the source code using submodules:
git clone --recurse-submodules https://github.com/CraigChat/craig.git - Configure environment variables by copying the example config:
Editcp ./install.config.example ./install.configinstall.configwith your Discord credentials (see Discord Bot Setup). - Run the installation script from the main directory:
The script requires./install.shsudoprivileges to install dependencies (likeredis,postgresql,ffmpeg, etc.) and configure the database. Errors and warnings are logged toinstall.log.
git clone --recurse-submodules https://github.com/CraigChat/craig.git cp ./install.config.example ./install.config ./install.sh- Clone the source code using submodules:
Self-hosting and installing Craig
masterTo self-host or install Craig, refer to the detailed instructions provided in theSELFHOST.mdfile within the repository.Configure tier-based access in Dropdown items
masterThe
Dropdowncomponent can automatically disable items based on a user's tier level.- Provide a
tierprop to theDropdowncomponent representing the user's current level. - Add a
tierRequiredproperty to specificDropdownItemobjects.
An item is considered disabled if:
item.disabledistrue.item.tierRequiredis greater than thetierprovided to theDropdown(andtieris not-1).
// If user tier is 0, 'Pro' will be disabled because it requires tier 1 <Dropdown tier={0} items={[ { title: 'Free', value: 'free' }, { title: 'Pro', value: 'pro', tierRequired: 1 } ]} />- Provide a
Use environment-specific configurations in slash-up
masterYou can define different settings for different environments using the
envproperty inslash-up.config.js. You can switch between these environments at runtime using the--envor-eCLI flag.For example, in a
developmentenvironment, you might want to use theglobalToGuildoption. This option forces global commands to sync to a specific guild ID instead of globally, which is useful for faster testing.// In slash-up.config.js env: { development: { globalToGuild: process.env.DEVELOPMENT_GUILD_ID } } // Run with the flag: // slash-up --env developmentConfigure install.config environment variables
masterThe
install.configfile manages the core environment for your Craig instance.Required Variables
DISCORD_BOT_TOKEN: Your Discord bot token.DISCORD_APP_ID: Your Discord application ID.CLIENT_ID: Your OAuth2 Client ID.CLIENT_SECRET: Your OAuth2 Client Secret.
Suggested Changes for Self-Hosting
API_HOST: Change from127.0.0.1to0.0.0.0to allow access from other machines on your network (especially useful in Docker/headless environments).API_HOMEPAGE: Set this to the IP address or domain name of your machine (e.g.,http://192.168.0.10:5029) so that download links generated by Craig are functional.
Initialize and connect the CraigBot
masterTo start the bot, call the
connect()function. This function performs several critical setup steps:- Loads core modules (Logger, Slash, Sharding, Recorder, etc.).
- Registers default commands:
eval,ping,kill,exec,load,unload,reload. - Initializes internationalization (i18n).
- Registers all command files found in the configured
commandsPath. - Connects to Redis and the Discord gateway via
Dexare. - Connects to the Prisma database.
- Starts the InfluxDB cron job.
To shut down the bot gracefully, call
disconnect(), which closes the Discord connection, Sentry, Prisma, and Redis.import { connect, disconnect } from './bot'; // Start the bot await connect(); // ... run bot ... // Graceful shutdown await disconnect();Deploy Craig using Docker Compose
masterCraig can be deployed using a
docker-compose.ymlfile that orchestrates three main services:db(PostgreSQL),redis, and thecraigapplication itself.Service Dependencies
- The
craigservice depends on thedbservice beingservice_healthyand theredisservice beingservice_started. - The
dbservice uses a healthcheck viapg_isreadyto ensure the database is ready before the application starts.
Port Mapping
- Craig Application: Maps ports
3000and5029to the host. - PostgreSQL: Maps port
5432to the host. - Redis: Maps port
6379to the host.
Volumes and Persistence
db_data: Persists PostgreSQL data.craig_rec: Persists application records at/app/recinside the container../install.config: The application expects a localinstall.configfile to be mounted as read-only at/app/install.config.
services: db: image: postgres environment: POSTGRES_PASSWORD: craig POSTGRES_DB: craig POSTGRES_USER: craig ports: - "5432:5432" volumes: - 'db_data:/var/lib/postgresql/data' redis: image: redis ports: - "6379:6379" craig: build: . ports: - "3000:3000" - "5029:5029" depends_on: db: condition: service_healthy redis: condition: service_started volumes: - 'craig_rec:/app/rec' - './install.config:/app/install.config:ro' volumes: db_data: craig_rec:- The
Troubleshoot HTTPS/Localhost download issues
masterCraig automatically serves download pages via
https://. If you are running onlocalhost, browsers may block the download because they lack a signed certificate forhttps://localhost.Workaround: Manually change the protocol from
https://tohttp://in your browser address bar.Example:
- Change
https://localhost:5029/rec/RECORDING_ID - To
http://localhost:5029/rec/RECORDING_ID
- Change