Discord rate limiting

​Protect Your Discord Servers from Raids with Rate Limiting​

1 hour
easy
1 submissions

Project Overview

​Protect Your Discord Servers from Raids with Rate Limiting​

The Discord Rate Limiting Service is designed to protect your Discord servers from disruptive activities, such as raids, by implementing customizable rate limits on user actions. This service allows server administrators to control the frequency of specific actions, thereby maintaining a safe and enjoyable environment for all members.

Key Features:

  • Multiple Server Support: Manage rate limits across multiple Discord servers simultaneously.

  • Independent Server Rate Limiting: Set individual rate limits for each server to tailor protection according to specific needs.

  • Global Rate Limiting: Implement overarching rate limits that apply across all managed servers to prevent widespread abuse.

Your submissions

No submissions yet, start by making your first submission

Detailed Project Description

Discord Rate Limiting Service Project Statement

Introduction

To safeguard your Discord server from disruptive activities such as raids and spam, implementing a rate-limiting service is essential. This project outlines the development of a Discord Rate Limiting Service designed to control the frequency of server creation and message sending, thereby enhancing the security and stability of your Discord community.

Features

  • Multiple Discord Servers: Manage rate limits across various Discord servers.
  • Independent Server Rate Limiting: Apply rate limits individually to each server.
  • Global Rate Limiting: Enforce rate limits across all servers collectively.

API Endpoints and Schemas

1. Create Server

  • Endpoint: POST /servers

  • Description: Adds a new Discord server to the rate-limiting service. Limited to 1 request every 4 seconds.

  • Request Body:

{ "name": "string" }
  • Response:

    • 201 Created:

      { "id": "string (uuid)", "name": "string", "createdAt": "string (date-time)" }
    • 429 Too Many Requests:

      { "error": "Rate limit exceeded. Only 1 server creation allowed every 4 seconds." }

2. Retrieve All Servers

  • Endpoint: GET /servers

  • Description: Fetches a list of all Discord servers managed by the rate-limiting service.

  • Response:

    • 200 OK:

      { "servers": [ { "id": "string (uuid)", "name": "string", "createdAt": "string (date-time)" } ] }

3. Send Message

  • Endpoint: POST /messages

  • Description: Sends a message to a specified server. Rate limited to 1 message every 5 seconds per server and 1 message every 3 seconds globally across all servers.

  • Request Body:

{ "serverId": "string (uuid)", "content": "string" }
  • Response:

    • 201 Created:

      { "id": "string (uuid)", "serverId": "string (uuid)", "content": "string", "sentAt": "string (date-time)" }
    • 429 Too Many Requests:

      { "error": "Rate limit exceeded. Limits are 1 message per 5 seconds per server and 1 message per 3 seconds globally." }

4. Retrieve All Messages

  • Endpoint: GET /messages

  • Description: Fetches a list of all messages sent across all servers.

  • Response:

    • 200 OK:

      { "messages": [ { "id": "string (uuid)", "serverId": "string (uuid)", "content": "string", "sentAt": "string (date-time)" } ] }

Implementation Guidelines

  • Rate Limiting: Implement rate limiting using middleware to enforce the specified limits on server creation and message sending.
  • Data Storage: Utilize an in-memory data store or SQLite to manage servers and messages.
  • UUIDs: Generate unique identifiers for servers and messages using UUIDs.
  • Timestamps: Record creation and sent times using ISO 8601 date-time format.
  • Error Handling: Provide meaningful error messages and appropriate HTTP status codes for different scenarios.

By implementing this Discord Rate Limiting Service, you can effectively mitigate the risk of raids and spam, ensuring a safer and more enjoyable environment for your server members.

Project Completion Criteria

  • The system should allow users to create a new server via POST /servers and return a 201 Created response.
  • The system should return a 429 Too Many Requests error if POST /servers is called more than once within 20 seconds by the same client.
  • The system should allow retrieving all servers using GET /servers and return an array containing the created servers.
  • The system should allow sending a message to a server via POST /messages and return a 201 Created response.
  • The system should allow retrieving all messages using GET /messages with an optional serverId filter.
  • The system should return a 429 Too Many Requests error if POST /messages is called more than once within 10 seconds for the same server.
  • The system should return a 429 Too Many Requests error if POST /messages is called more than once within 5 seconds globally across all servers.
  • All responses must match the expected structure defined in the test suite and include appropriate status codes and messages.