quick lil discord bot for the Structs ecosystem
1.8K
A Discord bot application for the Structs game ecosystem. This bot provides Discord slash commands for players to interact with the Structs game, manage structures, fleets, resources, and more.
/dev commandgit clone https://github.com/playstructs/structs-discord.git
cd structs-discord
npm install
.env file in the root directory with the following variables:# Discord Bot Configuration
DISCORD_TOKEN=your_discord_bot_token_here
DISCORD_CLIENT_ID=your_discord_client_id_here
# Database Configuration
DATABASE_URL=postgresql://user:password@host:port/database
# NATS Configuration (Optional)
# Defaults to nats://structs-nats:4222 if not set
NATS_URL=nats://structs-nats:4222
npm run dev
This uses nodemon to automatically restart the bot when files change.
npm start
Before running the bot, you need to deploy the slash commands to Discord:
npm run deploy
This registers all slash commands with Discord. You only need to run this when:
structs-discord/
├── src/
│ ├── commands/ # Discord slash commands
│ │ ├── struct.js # Structure management commands
│ │ ├── fleet.js # Fleet operations
│ │ ├── allocation.js # Energy allocations
│ │ └── ... # Other commands
│ ├── services/ # External service integrations
│ │ └── nats.js # NATS message service
│ ├── utils/ # Utility functions
│ ├── embeds/ # Discord embed builders
│ └── queries/ # Database query helpers
├── index.js # Bot entry point
├── deploy-commands.js # Command deployment script
└── package.json
The bot uses PostgreSQL functions in the signer schema for game transactions. See docs/API_REFERENCE.md for complete documentation.
Quick Reference:
tx_struct_build_initiate, tx_struct_build_complete, tx_struct_activate, etc.tx_fleet_move, tx_explore, tx_planet_raid_completetx_infuse, tx_bank_send, tx_guild_bank_redeemtx_allocation_create, tx_allocation_connect, tx_allocation_disconnect, tx_allocation_transfertx_substation_create, tx_substation_player_connect, tx_substation_player_disconnecttx_provider_create, tx_agreement_createtx_player_resumeFor detailed parameter documentation and function signatures, see docs/TRANSACTION_AUDIT.md.
npm test
Note: If Jest is not installed, add it to devDependencies:
npm install --save-dev jest
See Testing Guide for comprehensive testing documentation.
Commands follow a consistent pattern:
data: SlashCommandBuilder definitionautocomplete: (Optional) Autocomplete handler for dynamic optionsexecute: Command execution handlersrc/commands/data and execute propertiessrc/commands/index.jsnpm run deploy to register the command with Discordnpm run deployDISCORD_TOKEN is set correctlyDATABASE_URL is correctNATS_URL is correctContributions are welcome! Please ensure:
Comprehensive documentation is available in the docs/ directory:
Note: This bot project focuses on bot implementation documentation. For comprehensive game mechanics, API documentation, schemas, and protocols, see the Structs Compendium.
Access from Discord: Use /dev compendium command for quick links
Quick Start: New developers should start with the Documentation Index for a guided overview.
Apache-2.0
Content type
Image
Digest
sha256:971a6f465…
Size
800.9 MB
Last updated
10 months ago
docker pull structs/structs-discord