How It Works
The auto-reply system operates on a probability-based mechanism that resets after each successful reply:Initial Chance
When a channel is first added as a reply channel, the bot starts with a 6% chance to reply to any message.
Chance Increases
With each message sent in the channel (by non-bot users who haven’t opted out), the reply chance increases by 1%.
Reply Triggered
When a random number falls within the current chance percentage, the bot replies with a random phrase from your server’s phrase list.
The Probability System
The core reply logic generates a random number between 0-100 and compares it against the current chance:The chance percentage has a maximum cap of 100%, meaning after 94 consecutive messages without a reply, the bot is guaranteed to respond on the next message.
Cooldown System
To prevent spam and ensure natural conversation flow, AutoResponse implements a cooldown system:- After sending a reply, a cooldown period is activated for that channel
- During the cooldown, the bot will not reply regardless of the chance percentage
- Cooldown data is stored per server and channel in
replyCooldowns.db
User Opt-Out
Users who don’t want to receive replies can opt out at any time:Opt-Out Protection
Before any reply logic executes, AutoResponse checks if the message author is on the opt-out list. If they are, their messages are completely ignored by the auto-reply system.
How Opt-Out Works
- Users run
/optoutto add themselves to the opt-out list - Their username is stored in
optoutlist.dbglobally across all servers - Messages from opted-out users are logged with a red
OptOutprefix - Users can run
/optinat any time to start receiving replies again
Message Filtering
The auto-reply system only processes specific types of messages:| Message Type | Processed? | Reason |
|---|---|---|
| Regular user messages | ✅ Yes | Primary target for auto-replies |
| Bot messages | ❌ No | Prevents bot-to-bot loops |
| Webhook messages | ❌ No | Avoids replying to automated posts |
| System messages | ❌ No | System announcements shouldn’t be replied to |
| DMs | ❌ No | Only works in guild channels |
| Opted-out users | ❌ No | Respects user preferences |
| Cooldown active | ❌ No | Prevents spam |
Reply Selection
When the bot decides to reply:- It queries the server’s phrase database
- Randomly selects one phrase from all available phrases
- Sends the phrase as a reply to the triggering message
- Updates the leaderboard for the message author
- Resets the reply chance back to 6%
utils/reply.js:36-42:
Replies use Discord’s reply feature but with
allowedMentions: { repliedUser: false } to avoid pinging the user.Monitoring Reply Activity
AutoResponse provides detailed console logging for monitoring:- Green percentage: Current chance level for messages in reply channels
- Red “0%”: Messages in non-reply channels
- Red “OptOut”: Messages from opted-out users
- Red “Cooldown”: Messages blocked by active cooldown
- Server name, channel name, username, and message content are logged for each event
Best Practices
Configure multiple phrases
Configure multiple phrases
Add a diverse collection of reply phrases to keep responses varied and interesting. Use
/addphrase to build your phrase library.Monitor chance progression
Monitor chance progression
Watch the console logs to see how quickly the reply chance increases in active channels. This helps you understand reply frequency.
Respect user preferences
Respect user preferences
Always inform users about the
/optout command so they can control their experience with the bot.Choose appropriate channels
Choose appropriate channels
Enable auto-replies in casual, social channels rather than important announcement or support channels.
Technical Details
Reply chance data is persisted in SQLite:- Database:
data/{serverId}.db - Table:
replyChannels - Schema:
(id TEXT PRIMARY KEY, chance INTEGER) - Chance value is updated after every message in a reply channel