# Discord

> Read guilds, channels, members and message history from Discord, post messages, and decode Discord ids and permissions

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/discord.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `discord`. Release: [v0.1.0](https://github.com/Query-farm/vgi-discord/releases/tag/v0.1.0). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-discord) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosting is not currently offered for this connector.

## Service credentials and prerequisites

Supply your own service credentials or required connection options before querying protected data.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

After installing VGI and attaching the connector, create the required secrets using your own values. Replace placeholders and omit unused optional parameters from the templates below.

### discord

Discord bot token (and optional API base URL) used by the discord worker's API functions.
[Credential instructions](https://discord.com/developers/docs/quick-start/getting-started)

```json
[
  {
    "name": "token",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "Discord bot token, from the Bot page of your application in the Discord Developer Portal (Reset Token to reveal it)."
  },
  {
    "name": "api_base",
    "type": "VARCHAR",
    "required": false,
    "redact": false,
    "description": "Optional Discord API base URL; defaults to https://discord.com/api/v10."
  }
]
```

```sql
CREATE SECRET discord (
    TYPE discord,
    token    '<DISCORD_TOKEN>',  -- secret
    api_base '<api_base>'
);
```

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### From GitHub

Attach the release directly

Uses the verified release each time you attach the connector.

```sql
ATTACH 'discord' AS discord (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-discord@v0.1.0'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'discord' AS discord (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-discord:0.1.0'
);
```

## The first four flags

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
SELECT name, bit FROM discord.main.permission_flags WHERE bit < 4 ORDER BY bit
```

- [discord.main.permission_flags — table](https://query.farm/products/orchard/connectors/discord/objects/table.bWFpbg.cGVybWlzc2lvbl9mbGFncw.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T21:55:12+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.1.0",
  "sample": {
    "columns": [
      "name",
      "bit"
    ],
    "types": [
      "VARCHAR",
      "INTEGER"
    ],
    "rows": [
      [
        "CREATE_INSTANT_INVITE",
        0
      ],
      [
        "KICK_MEMBERS",
        1
      ],
      [
        "BAN_MEMBERS",
        2
      ],
      [
        "ADMINISTRATOR",
        3
      ]
    ],
    "more": false
  }
}
```

## Connector reference

### Discord for DuckDB

**Read servers, channels, members and message history from Discord, and post messages back, all from SQL.** A [VGI](https://query.farm/vgi) worker over the Discord REST API (v10), using a bot token.

- **Analyze** activity: message history, reactions, pins, threads, member joins.
- **Audit** structure: channels, roles and permissions, emojis, scheduled events.
- **Act**: send one message or one per row, post via webhooks, edit, delete, react. Mentions never ping unless you opt in.
- **Decode** snowflake ids, build time-window cursors, format mentions and timestamps.

Store the bot token in a DuckDB secret of type `discord` (or the `DISCORD_BOT_TOKEN` environment variable). Rate limits are respected automatically.

## Find the exact SQL object

[Browse 36 object declarations](https://query.farm/products/orchard/api/v1/connectors/discord/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=discord&q=discord).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-discord",
  "harvest": {
    "status": "ok",
    "method": "github-auto",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 17,
    "passed": 17,
    "failed": 0,
    "needs_credentials": 0,
    "location": "github-auto://Query-farm/vgi-discord@v0.1.0",
    "transport": "github-auto",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.13.13",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T21:54:43+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
