Sending messages in a channel

Rate Limit Details

Limit
5
requests
Window
5
seconds
Bucket
channel
scope
Category
Messages
type

Calculated Metrics

Requests per Second
1.00
Requests per Minute
60
Requests per Hour
3600
Optimal Delay
1000ms
Time Estimate

Making 10 requests to Send Message will take approximately:

10.0 seconds
// Discord.js - Rate Limit Handling

// Discord.js automatically handles rate limits
// You don't need to manually implement delays

const { REST } = require('@discordjs/rest');
const rest = new REST({ version: '10' }).setToken('YOUR_BOT_TOKEN');

// Example: Send multiple messages with automatic rate limit handling
async function sendMultipleMessages(channel, messages) {
  for (const content of messages) {
    try {
      await channel.send(content);
      // Discord.js automatically waits if rate limited
    } catch (error) {
      if (error.code === 429) {
        // Rate limited - Discord.js will retry automatically
        console.log('Rate limited, waiting...');
      } else {
        console.error('Error:', error);
      }
    }
  }
}

// Listen for rate limit events
client.rest.on('rateLimited', (info) => {
  console.log(`Rate limited on route ${info.route}`);
  console.log(`Retry after: ${info.timeToReset}ms`);
  console.log(`Limit: ${info.limit}`);
  console.log(`Global: ${info.global}`);
});

// Manual delay for custom logic (1000ms for Send Message)
async function sendWithDelay(channel, messages) {
  for (const content of messages) {
    await channel.send(content);
    await new Promise(resolve => setTimeout(resolve, 1000));
  }
}
ℹ️

Global Rate Limit

Discord has a global rate limit of 50 requests per second across all endpoints. Libraries handle this automatically.

⚠️

429 Status Code

When rate limited, Discord returns HTTP 429. The response includes a Retry-After header indicating wait time.

Powered by Mamba Host