Lightweight Node.js bot project for generating fansigns and managing fonts, images, and related assets.
This repository contains the bot code, font assets, and utilities used to generate and process fonts and images. It includes the core bot (bot.js), command handlers, and asset folders.
- Bot entry:
bot.js - Command handlers in
commands/ - Font sources in
ALL/new fonts/andfonts/
This repository contains a Discord fansign generator bot that renders realistic, handcrafted-looking fansign images from user text and selected styles.
Quick links: - bot.js - deploy.js - console.js - LICENSE
Where to look: - Commands: commands/ (key files: commands/fansignRender.js, commands/fansign2.js, commands/fansign3.js, commands/info.js) - Fonts: fonts/ and ALL/new fonts/ - Config: config/ (notably config/styles.json and config/blacklist.json) - Utilities: utils/concurrencyManager.js
Author / Attribution: Created and maintained by the repository owner. All code, fonts, images and assets in this repository were authored by the project owner.
License: MIT -- see LICENSE.
Stack & dependencies (found in package.json):
- Node.js (recommended 18+)
- discord.js, canvas, jimp, sharp, and small utilities (see
package.json)
Purpose: This bot generates high-quality fansign images on demand using a multi-stage rendering pipeline that simulates handwriting, ink behavior, paper grain, textures and lighting.
Important: Do not commit secrets. Provide DISCORD_TOKEN, CLIENT_ID and GUILD_ID via environment variables or a local .env file.
Run modes:
node bot.js-- run the bot directlynode console.js-- run the management console (start/stop/sync/reload commands, see console help)node deploy.js-- register slash commands (used by thesyncconsole command)
Install & setup
- Install Node.js (18+).
- From project root, install dependencies:
npm install- Create a
.envfile in the repo root with at least:
DISCORD_TOKEN=your_bot_token_here
CLIENT_ID=your_application_client_id
GUILD_ID=your_development_guild_id
- Register slash commands (one-time per guild during development):
node deploy.js- Start the bot (or use
console.jsto manage it):
node console.js
# then in the console type: startOr run directly:
node bot.jsNotes for canvas on Windows: canvas may require system libraries (Cairo, build tools). If install fails, install the platform prerequisites or use prebuilt binaries.
Commands & main features
- /fs -- Fansign generator (styles 1–25) -- implemented in commands/fansignRender.js
- /fs2 -- Fansign generator (styles 26–50) -- commands/fansign2.js (proxies to the main renderer)
- /fs3 -- Fansign generator (styles 51–54) -- commands/fansign3.js
- /info -- Multi-page info about the bot and features -- commands/info.js
- /help -- Short help embed -- commands/help.js
- /ping -- Latency check -- commands/ping.js
The commands are loaded by bot.js at startup and registered as slash commands via deploy.js.
Configuration & data files
- config/styles.json: Defines available fansign styles, images, font defaults and per-style rendering parameters. The bot watches this file and reloads it on change.
- config/blacklist.json: Words that are not allowed in fansign text.
- config/banlist.json: Moderation bans (managed via the console
ban/unbancommands). - config/config.json: General app config (version etc.).
Rendering pipeline
- Style & asset selection: picks the style entry from
styles.json(image, base parameters). - Font selection: user can pick a.ttffrom fonts/; the renderer registers fonts and attempts fallbacks when glyphs are missing. - Background analysis: reads the style image and computes brightness, contrast and edge strength to adapt ink opacity, halo and skew. - Layout & wrapping: adaptive font sizing and word-wrapping ensures text fits the chosen canvas. - Character-level rendering: the engine positions and transforms each character with subtle rotation, skew, pressure and color variation to simulate handwriting. - Paper & ink simulation: multi-scale noise, fiber simulation, depth/normal estimation and ink diffusion create realistic ink spread and texture. - Post-processing: Jimp is used for optional blur, pixelation, overlays and compositing with paper/texture images. - Output: the result is returned to the user as a JPEG attachment with a randomized filename.
Moderation, rate-limits & concurrency
- Per-user cooldowns: A short processing cooldown is applied via
utils/concurrencyManager.js(default processing cooldown set in the code). Fansign commands also maintain per-user cooldowns (regular users ~60s, boosters/role bypass if present). - Concurrency control:utils/concurrencyManager.jslimits simultaneous render jobs (default maximum 3). - Blacklist:config/blacklist.jsonis checked and rejects requests with forbidden words. - Banlist:config/banlist.jsoncontains bans that block users from running commands (except/helpand/info).
Privacy & logging
- The bot prints logs to the console only; it does not externally store user request contents. The info command and module text explicitly say "No Log Policy". The console stores ban and concurrency state in
config/files.
Developer notes & tips
- Add or edit styles in [config/styles.json] to add new fansign templates (image, coordinates, font defaults, effects). The bot watches this file and reloads styles while running. - Add fonts by putting
.ttffiles in the fonts/ folder. The command UIs will list available fonts automatically. - To update slash commands after adding or modifying commands, runnode deploy.jsor use thesynccommand inconsole.js. - If you need to resolve user IDs from the console,resolveUser.jscan be invoked by the console code (it uses a token argument).
Troubleshooting
- Canvas install errors: ensure native build tools and Cairo are available (Windows: install Windows Build Tools and Cairo). - Missing environment vars: ensure
DISCORD_TOKEN,CLIENT_IDandGUILD_IDare set. - Commands not appearing: rerunnode deploy.js(and make sureCLIENT_IDandGUILD_IDare correct during development).
Next steps I can help with
- Add
authorandrepositoryfields topackage.json, updatepackage.jsonwith your name. - CreateCONTRIBUTING.md,ISSUE_TEMPLATE, or a GitHub Actions workflow to run lint/tests. - Trim or document required system libraries forcanvasbuild on Windows.
If you want, I can update package.json with your name and repo link and then add a simple CI workflow. Reply and I will make those changes.
