Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/nuke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ on:
description: "Eas"
type: boolean
default: false
discord:
description: "Discord"
type: boolean
default: false

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pr-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'force-ci')
run: |
set -euo pipefail
all='["core","aws","cloudflare","gcp","neon","planetscale","prisma-postgres","stripe","supabase","posthog","axiom","azure","kubernetes","coinbase","mongodb-atlas","fly-io","turso","typesense","workos","expo-eas"]'
all='["core","aws","cloudflare","gcp","neon","planetscale","prisma-postgres","stripe","supabase","posthog","axiom","azure","kubernetes","coinbase","mongodb-atlas","fly-io","turso","typesense","workos","expo-eas","discord"]'
echo "packages=${all}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
Expand Down Expand Up @@ -102,6 +102,9 @@ jobs:
expo-eas:
- 'packages/expo-eas/**'
- 'packages/core/**'
discord:
- 'packages/discord/**'
- 'packages/core/**'

# ── Compute tags once so every matrix job + the comment use the same set. ─
tags:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ env:
packages/typesense/package.json
packages/workos/package.json
packages/expo-eas/package.json
packages/discord/package.json
bun.lock
CHANGELOG.md

Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
typesense: ${{ steps.force.outputs.all || steps.changes.outputs.typesense }}
workos: ${{ steps.force.outputs.all || steps.changes.outputs.workos }}
expo-eas: ${{ steps.force.outputs.all || steps.changes.outputs.expo-eas }}
discord: ${{ steps.force.outputs.all || steps.changes.outputs.discord }}
steps:
- id: force
if: contains(github.event.pull_request.labels.*.name, 'force-ci')
Expand Down Expand Up @@ -110,6 +111,9 @@ jobs:
expo-eas:
- 'packages/expo-eas/**'
- 'packages/core/**'
discord:
- 'packages/discord/**'
- 'packages/core/**'

ci-core:
needs: detect-changes
Expand Down Expand Up @@ -494,3 +498,25 @@ jobs:
working-directory: packages/expo-eas
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}

ci-discord:
needs: detect-changes
if: needs.detect-changes.outputs.discord == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
- run: bun run build
working-directory: packages/core
- run: bun run check
working-directory: packages/discord
- run: bun run test
working-directory: packages/discord
env:
DISCORD_API_BASE_URL: ${{ secrets.DISCORD_API_BASE_URL }}
DISCORD_BEARER_TOKEN: ${{ secrets.DISCORD_BEARER_TOKEN }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
19 changes: 19 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions packages/discord/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# @distilled.cloud/discord

Effect-native Discord SDK generated from the [Discord HTTP API specification](https://github.com/discord/discord-api-spec). Manage applications, guilds, channels, members, messages, interactions, webhooks, and more with exhaustive error typing.

## Installation

```bash
npm install @distilled.cloud/discord effect
```

## Quick Start

```typescript
import { Effect, Layer } from "effect";
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
import { getMyUser } from "@distilled.cloud/discord/Operations";
import { CredentialsFromEnv } from "@distilled.cloud/discord";

const program = Effect.gen(function* () {
const me = yield* getMyUser({});
return me;
});

const DiscordLive = Layer.mergeAll(FetchHttpClient.layer, CredentialsFromEnv);

program.pipe(Effect.provide(DiscordLive), Effect.runPromise);
```

## Configuration

Set one of the following environment variables:

```bash
# Bot token (most common) — sent as `Authorization: Bot <token>`
DISCORD_BOT_TOKEN=your-bot-token

# Or, for OAuth2 — sent as `Authorization: Bearer <token>`
DISCORD_BEARER_TOKEN=your-bearer-token

# Optional override
DISCORD_API_BASE_URL=https://discord.com/api/v10
```

`DISCORD_TOKEN` is accepted as an alias for `DISCORD_BOT_TOKEN`. Create a bot
token in the [Discord Developer Portal](https://discord.com/developers/applications)
under **Your App > Bot**.

## Error Handling

```typescript
import { Effect } from "effect";
import { getUser } from "@distilled.cloud/discord/Operations";
import {
NotFound,
DiscordRateLimited,
UnknownDiscordError,
} from "@distilled.cloud/discord/Errors";

getUser({ user_id: "0" }).pipe(
Effect.catchTags({
NotFound: (_e: NotFound) => Effect.succeed(null),
DiscordRateLimited: (e: DiscordRateLimited) =>
Effect.fail(new Error(`Rate limited; retry after ${e.retryAfter}s`)),
UnknownDiscordError: (e: UnknownDiscordError) =>
Effect.fail(new Error(`Unknown: ${e.message}`)),
}),
);
```

## Services

Operations cover the full Discord v10 HTTP API. Notable groups:

- **Applications** — get/update application, commands, emojis, entitlements, role connections
- **Guilds** — create, get, update, delete; members, roles, bans, invites, integrations, widgets, scheduled events, audit log
- **Channels** — create, get, update, delete; permissions, invites, pins, threads, followers
- **Messages** — create, get, list, update, delete, crosspost, reactions, bulk delete
- **Interactions** — respond, edit, delete; webhook follow-ups
- **Users** — current user, DMs, connections, guilds
- **Webhooks** — create, get, update, delete, execute (incl. Slack/GitHub-compatible)
- **Stage Instances, Stickers, Soundboard, Lobbies, Polls, Voice Regions, OAuth2**

See `src/operations/` for the full list (200+ operations).

## License

MIT
88 changes: 88 additions & 0 deletions packages/discord/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"name": "@distilled.cloud/discord",
"version": "0.2.0-alpha",
"repository": {
"type": "git",
"url": "https://github.com/alchemy-run/distilled",
"directory": "packages/discord"
},
"type": "module",
"sideEffects": false,
"module": "src/index.ts",
"files": [
"lib",
"src"
],
"exports": {
".": {
"types": "./lib/index.d.ts",
"bun": "./src/index.ts",
"default": "./lib/index.js"
},
"./Category": {
"types": "./lib/category.d.ts",
"bun": "./src/category.ts",
"default": "./lib/category.js"
},
"./Client": {
"types": "./lib/client.d.ts",
"bun": "./src/client.ts",
"default": "./lib/client.js"
},
"./Credentials": {
"types": "./lib/credentials.d.ts",
"bun": "./src/credentials.ts",
"default": "./lib/credentials.js"
},
"./Errors": {
"types": "./lib/errors.d.ts",
"bun": "./src/errors.ts",
"default": "./lib/errors.js"
},
"./Operations": {
"types": "./lib/operations/index.d.ts",
"bun": "./src/operations/index.ts",
"default": "./lib/operations/index.js"
},
"./Retry": {
"types": "./lib/retry.d.ts",
"bun": "./src/retry.ts",
"default": "./lib/retry.js"
},
"./Sensitive": {
"types": "./lib/sensitive.d.ts",
"bun": "./src/sensitive.ts",
"default": "./lib/sensitive.js"
},
"./Traits": {
"types": "./lib/traits.d.ts",
"bun": "./src/traits.ts",
"default": "./lib/traits.js"
}
},
"scripts": {
"typecheck": "tsgo",
"build": "tsgo -b",
"fmt": "oxfmt --write src",
"lint": "oxlint --fix src",
"check": "tsgo && oxlint src && oxfmt --check src",
"test": "bunx vitest run test --passWithNoTests",
"publish:npm": "bun run build && bun publish --access public",
"generate": "bun run scripts/generate.ts && oxlint --fix src && oxfmt --write src && oxfmt --write src",
"specs:fetch": "echo 'No specs configured'",
"specs:update": "echo 'No specs configured'"
},
"dependencies": {
"@distilled.cloud/core": "workspace:*",
"effect": "catalog:"
},
"devDependencies": {
"@types/bun": "catalog:",
"@types/node": "catalog:",
"dotenv": "catalog:",
"vitest": "catalog:"
},
"peerDependencies": {
"effect": "catalog:"
}
}
Loading
Loading