Skip to main content
AutoResponse uses an intelligent incremental chance system to provide natural, unpredictable auto-replies in configured channels. The bot starts with a low reply chance that gradually increases with each message until a reply is triggered.

How It Works

The auto-reply system operates on a probability-based mechanism that resets after each successful reply:
1

Initial Chance

When a channel is first added as a reply channel, the bot starts with a 6% chance to reply to any message.
2

Chance Increases

With each message sent in the channel (by non-bot users who haven’t opted out), the reply chance increases by 1%.
3

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.
4

Chance Resets

After sending a reply, the chance immediately resets back to 6%, and the cycle begins again.

The Probability System

The core reply logic generates a random number between 0-100 and compares it against the current chance:
const randomChance = Math.random() * 100;

if (randomChance <= chance) {
    replyToUser(message);
    
    // Reset chance back to starting value
    replyChannel.chance = 6;
} else {
    // Increase chance by 1%, capped at 100%
    chance = Math.min(chance + 1, 100);
}
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
const cooldownTimeRemaining = await getCooldownTimeRemaining(serverId, channelId);
if (cooldownTimeRemaining > 0) {
    // Skip reply logic during cooldown
    return;
}
Cooldown times are managed automatically. Administrators cannot manually clear cooldowns through commands.

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

  1. Users run /optout to add themselves to the opt-out list
  2. Their username is stored in optoutlist.db globally across all servers
  3. Messages from opted-out users are logged with a red OptOut prefix
  4. Users can run /optin at any time to start receiving replies again
const optOutList = await getOptOutList();

if (optOutList.includes(authorUsername)) {
    // Skip all auto-reply logic
    return;
}

Message Filtering

The auto-reply system only processes specific types of messages:
Message TypeProcessed?Reason
Regular user messages✅ YesPrimary target for auto-replies
Bot messages❌ NoPrevents bot-to-bot loops
Webhook messages❌ NoAvoids replying to automated posts
System messages❌ NoSystem announcements shouldn’t be replied to
DMs❌ NoOnly works in guild channels
Opted-out users❌ NoRespects user preferences
Cooldown active❌ NoPrevents spam
The bot logs all messages with color-coded prefixes showing the chance percentage, making it easy to monitor reply activity in your console.

Reply Selection

When the bot decides to reply:
  1. It queries the server’s phrase database
  2. Randomly selects one phrase from all available phrases
  3. Sends the phrase as a reply to the triggering message
  4. Updates the leaderboard for the message author
  5. Resets the reply chance back to 6%
From utils/reply.js:36-42:
const phrases = await getPhrases(db);

if (phrases.length > 0) {
    const randomIndex = Math.floor(Math.random() * phrases.length);
    const randomPhrase = phrases[randomIndex];
    
    await message.reply({
        content: randomPhrase,
        allowedMentions: { repliedUser: false },
    });
}
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

Add a diverse collection of reply phrases to keep responses varied and interesting. Use /addphrase to build your phrase library.
Watch the console logs to see how quickly the reply chance increases in active channels. This helps you understand reply frequency.
Always inform users about the /optout command so they can control their experience with the bot.
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
The incremental system ensures replies feel natural and unpredictable while guaranteeing eventual responses in active channels.

Build docs developers (and LLMs) love