SDKs overview

Dangerous Discord Database provides a set of tools and services designed for Discord server moderation and community safety. Its API allows developers to programmatically manage user reports, submit new moderation events, and interact with the platform's core features. To facilitate integration, Dangerous Discord Database offers official Software Development Kits (SDKs) in several programming languages, abstracting the underlying RESTful API calls and handling authentication, request formatting, and response parsing (Dangerous Discord Database API reference).

SDKs are designed to streamline development by providing idiomatic interfaces for each language, reducing the boilerplate code required to interact with the API. This enables developers to focus on application logic rather than the specifics of HTTP requests or JSON parsing. Beyond official offerings, a community of developers contributes third-party libraries, often extending functionality or providing support for additional languages and frameworks.

When selecting an SDK, developers typically consider factors such as language compatibility, feature completeness, maintenance status, and community support. The official SDKs are maintained by Dangerous Discord Database and are generally recommended for their direct support and alignment with API updates (Dangerous Discord Database official SDKs page). Community libraries, while offering broader language support or specialized features, may vary in maintenance frequency and adherence to API changes.

Official SDKs by language

Dangerous Discord Database maintains official SDKs for popular programming languages, providing tested and supported interfaces to its API. These SDKs are developed to ensure compatibility with the latest API versions and offer a consistent developer experience across different environments. The table below details the currently available official SDKs, their respective package names, installation commands, and maturity levels.

Language Package Name Install Command Maturity
Python dangerous-discord-database-py pip install dangerous-discord-database-py Stable
JavaScript/TypeScript @ddd/sdk npm install @ddd/sdk or yarn add @ddd/sdk Stable
Go github.com/ddd/go-sdk go get github.com/ddd/go-sdk Stable

Each official SDK is distributed through its language's standard package manager, allowing for straightforward integration into existing projects. Developers can find detailed API documentation and usage examples specific to each SDK on the Dangerous Discord Database SDK documentation.

Installation

Installing a Dangerous Discord Database SDK typically involves using the package manager native to your chosen programming language. The specific commands vary by language, but the general process is to add the SDK package as a dependency to your project. This ensures that the necessary libraries are downloaded and made available for use in your code.

Python SDK Installation

To install the Python SDK, use pip, the Python package installer:

pip install dangerous-discord-database-py

After installation, you can import the SDK into your Python scripts:

from ddd_sdk import DangerousDiscordDatabaseClient

# Your code here

JavaScript/TypeScript SDK Installation

For JavaScript and TypeScript projects, use npm or yarn to install the package:

# Using npm
npm install @ddd/sdk

# Or using yarn
yarn add @ddd/sdk

You can then import the client in your JavaScript or TypeScript files:

// For JavaScript (CommonJS)
const { DangerousDiscordDatabaseClient } = require('@ddd/sdk');

// For JavaScript (ES Modules) or TypeScript
import { DangerousDiscordDatabaseClient } from '@ddd/sdk';

// Your code here

Go SDK Installation

To add the Go SDK to your project, use the go get command:

go get github.com/ddd/go-sdk

Then, import the package in your Go source files:

package main

import (
	"github.com/ddd/go-sdk/client"
)

func main() {
	// Your code here
}

For more detailed installation instructions and system requirements, consult the Dangerous Discord Database installation guide.

Quickstart example

This quickstart example demonstrates how to initialize the Dangerous Discord Database client and perform a basic operation, such as submitting a new user report. This example uses the Python SDK.

import os
from ddd_sdk import DangerousDiscordDatabaseClient
from ddd_sdk.models import NewUserReport, ReportSeverity

# Initialize the client with your API key
# It's recommended to load the API key from environment variables
client = DangerousDiscordDatabaseClient(api_key=os.environ.get("DDD_API_KEY"))

def submit_new_report(user_id: str, guild_id: str, reason: str, severity: ReportSeverity):
    """
    Submits a new user report to Dangerous Discord Database.
    """
    try:
        report_data = NewUserReport(
            user_id=user_id,
            guild_id=guild_id,
            reason=reason,
            severity=severity.value # Ensure enum value is passed
        )
        response = client.reports.submit_report(report_data)
        print(f"Report submitted successfully: {response.report_id}")
        return response
    except Exception as e:
        print(f"Error submitting report: {e}")
        return None

if __name__ == "__main__":
    # Example usage:
    # Ensure DDD_API_KEY is set in your environment variables
    if not os.environ.get("DDD_API_KEY"):
        print("Error: DDD_API_KEY environment variable not set.")
        print("Please set it before running the script.")
    else:
        # Submitting a critical report
        submit_new_report(
            user_id="123456789012345678",
            guild_id="987654321098765432",
            reason="Repeated harassment and hate speech in general chat.",
            severity=ReportSeverity.CRITICAL
        )

        # Submitting a moderate report
        submit_new_report(
            user_id="112233445566778899",
            guild_id="987654321098765432",
            reason="Spamming promotional links in multiple channels.",
            severity=ReportSeverity.MODERATE
        )

This example demonstrates the basic steps: client initialization with an API key and calling a method to interact with the reports endpoint. The NewUserReport model helps structure the data according to the API's requirements. For production environments, sensitive information like API keys should always be managed securely, typically through environment variables or secure configuration management systems (Google Cloud's guide on secrets management).

For more comprehensive examples and details on other API operations, refer to the Dangerous Discord Database quickstart guides.

Community libraries

In addition to the official SDKs, the Dangerous Discord Database ecosystem includes community-contributed libraries. These libraries often extend functionality, offer integrations with specific frameworks, or provide support for languages not covered by official SDKs. Community libraries are developed and maintained independently by developers and can sometimes offer experimental features or specialized solutions.

While community libraries can be valuable, it is important to verify their maintenance status, documentation quality, and compatibility with the latest Dangerous Discord Database API versions. Developers should review the source code, check for recent updates, and read user reviews before integrating a community library into a production application. Resources like GitHub and language-specific package repositories (e.g., PyPI for Python, npm for JavaScript) are common places to discover and evaluate these libraries.

Examples of potential community contributions might include:

  • Rust client library: A wrapper for the Dangerous Discord Database API written in Rust.
  • PHP SDK: A library for integrating with the API from PHP applications.
  • Discord.js integration: A module that specifically integrates Dangerous Discord Database features within Discord.js bots, simplifying common moderation workflows.
  • CLI tools: Command-line interfaces built on top of the API for quick administrative tasks.

Dangerous Discord Database encourages community contributions and often lists notable third-party tools on its community projects page. Developers interested in contributing or finding community solutions are advised to consult these resources and engage with the broader developer community.