How palopil/counter-bot-js works
counter-bot is a Discord bot for configuring per-server counting channels and enforcing sequential counts. The main workflow is: a server administrator runs /setup, the bot saves the rules and posts the starting number, then message events load those rules, evaluate submitted expressions through the external Matheval service, and update the count or apply a timeout role. Edit and delete events also protect the current count. The sampled source shows these paths; other runtime wiring is limited to the event and command loader in index.js.
Main entry points: setup.js Setup command · utils.js Count utilities · messageCreate.js New messages · messageUpdate.js Edited messages
Components 14
Server setup
- Setup command
commands/setup.js - Guild configuration
commands/setup.js - Starting number
commands/setup.js
Counting workflow
- New messages
events/messageCreate.js - Edited messages
events/messageUpdate.js - Deleted messages
events/messageDelete.js - Count utilities
lib/utils.js - Matheval calculator
- Timeout role
Bot runtime
- Interaction router
events/interactionCreate.js - Event and command loader
index.js - Ready presence
events/ready.js
Other components
- Server admin
- Discord
Connections 23
- Server admin → Setup command: runs setup
commands/setup.js - Discord → Setup command: delivers interaction
- Setup command → Guild configuration: writes settings
commands/setup.js - Setup command → Starting number: posts start
commands/setup.js - Setup command → Discord: replies with embed
commands/setup.js - Discord → Interaction router: delivers interactions
- Interaction router → Setup command: dispatches command
events/interactionCreate.js - Discord → New messages: delivers messages
- Discord → Edited messages: delivers edits
- Discord → Deleted messages: delivers deletions
- New messages → Count utilities: loads and updates count
events/messageCreate.js - Edited messages → Count utilities: loads and parses count
events/messageUpdate.js - Deleted messages → Count utilities: loads and parses count
events/messageDelete.js - Count utilities → Guild configuration: reads and writes state
lib/utils.js - Count utilities → Matheval calculator: posts expression
lib/utils.js - New messages → Discord: reacts or deletes
events/messageCreate.js - New messages → Timeout role: applies timeout
events/messageCreate.js - Edited messages → Timeout role: applies timeout
events/messageUpdate.js - Deleted messages → Timeout role: applies timeout
events/messageDelete.js - Edited messages → Discord: restores original
events/messageUpdate.js - Deleted messages → Discord: reposts deleted count
events/messageDelete.js - Discord → Ready presence: signals ready
- Event and command loader → Discord: registers handlers
index.js