📁 File Structure
Project layout
fluxer-ticket-bot/
├── .env ← secrets (never commit)
├── .env.example ← template for .env
├── .gitignore
├── config.json ← bot configuration
├── config.example.json ← template for config.json
├── package.json
│
├── src/
│ ├── index.js ← entry point, event wiring
│ ├── config.js ← loads & validates .env + config.json
│ ├── constants.js ← magic numbers & shared constants
│ │
│ ├── commandHandler.js ← admin text command router
│ ├── reactionHandler.js ← reaction event handler (panel + controls)
│ ├── ticketManager.js ← channel create & close logic
│ ├── archiver.js ← transcript fetch, render, save, DM
│ │
│ ├── builders.js ← embed construction helpers
│ ├── panel.js ← posts the panel embed + reactions
│ ├── permissions.js ← permission bitfields + overwrite builder
│ ├── store.js ← in-memory state (open tickets, pending, panels)
│ └── utils.js ← logging, snowflake utils, rate limiting, etc.
│
└── transcript-archive/ ← auto-created; HTML transcripts saved here
└── *.html
Module responsibilities
index.js
Entry point. Creates the @fluxerjs/core Client, registers event handlers for MessageCreate and MessageReactionAdd, and calls client.login().
config.js
Loads .env via dotenv, reads config.json, validates every field, and exports a single config object used throughout the codebase. Calls process.exit(1) with a clear error message on validation failure.
constants.js
Single source of truth for all magic numbers: timeouts, emoji lists, colour codes, regex patterns, CDN URLs, etc.
commandHandler.js
Handles !ticket <subcommand> text commands. Routes to panel, close, id, transcript, and help handlers.
reactionHandler.js
Handles the reaction-based ticket creation flow (panel → confirmation → ticket creation) and the ticket control reactions (lock / unlock / close on the welcome message).
ticketManager.js
Contains createTicket() and closeTicket(). Responsible for channel creation with correct permissions, welcome message posting, archiving on close, and channel deletion.
archiver.js
Fetches all channel messages, renders a self-contained HTML transcript, saves it to disk, and optionally DMs it to the opener and log user.
builders.js
Pure functions that return embed objects: panel embed, welcome embed, close embed, confirm embed, duplicate embed, error embed.
panel.js
Posts the panel embed in the configured channel and adds the numbered reactions.
permissions.js
Defines the Fluxer permissions bitfield constants and buildPermissionOverwrites() which produces the array of overwrites for a new ticket channel.
store.js
In-memory Maps and Sets tracking: open tickets (userId → channelId), ticket owners (channelId → userId), ticket metadata, panel message IDs, and pending confirmation selections. Note: state is lost on restart. Swap Maps for SQLite/JSON to persist across restarts.
utils.js
Shared utilities: structured logger, snowflakeToDate(), sanitizeUsername(), escapeHtml(), CooldownTracker, sendTemporaryMessage(), retry(), and more.