aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/discord.md
blob: d3e9c5a2b7ab1873fd66f973bb394624acc20e9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Creating a Discord bot with Bun

Discord bots perform actions in response to _application commands_. There are 3 types of commands accessible in different interfaces: the chat input, a message's context menu (top-right menu or right-clicking in a message), and a user's context menu (right-clicking on a user).

To get started you can use the interactions template:

```bash
bun create discord-interactions my-interactions-bot
cd my-interactions-bot
```

If you don't have a Discord bot/application yet, you can create one [here (https://discord.com/developers/applications/me)](https://discord.com/developers/applications/me).

Invite bot to your server by visiting `https://discord.com/api/oauth2/authorize?client_id=<your_application_id>&scope=bot%20applications.commands`

Afterwards you will need to get your bot's token, public key, and application id from the application page and put them into `.env.example` file

Then you can run the http server that will handle your interactions:

```bash
$ bun install
$ mv .env.example .env
$ bun run.js # listening on port 1337
```

Discord does not accept an insecure HTTP server, so you will need to provide an SSL certificate or put the interactions server behind a secure reverse proxy. For development, you can use ngrok/cloudflare tunnel to expose local ports as secure URL.
invalid fd error (#1386)Gravatar Carter Snook 2-1/+15 2022-10-23Preserve trailing newline when updating package.jsonGravatar Jarred Sumner 2-0/+14 2022-10-23Fix `ReadableStream.prototype.tee`Gravatar Jarred Sumner 3-2/+61 2022-10-23Add Web Crypto API (#1384)Gravatar Jarred Sumner 240-49/+18727 2022-10-23fix(fetch): stop `new Response(null)` from segfaulting (#1383)Gravatar Carter Snook 1-8/+1 2022-10-22Fix spawn exitcode (#1371)Gravatar zhiyuan 2-1/+30 2022-10-21Add sqlite to include listGravatar Jarred Sumner 1-1/+4 2022-10-21CodegenGravatar Jarred Sumner 2-16/+25 2022-10-21Treat invalid buffer value as utf8 stringGravatar Jarred Sumner 1-2/+3 2022-10-21Add test for `fs.createReadStream`Gravatar Jarred Sumner 1-0/+43 2022-10-21Implement `fs.createReadStream`, begin `fs.createWriteStream`Gravatar Jarred Sumner 1-3/+621 2022-10-21Make Node Streams work better in BunGravatar Jarred Sumner 1-140/+214 2022-10-21Fix error handling logic in read()Gravatar Jarred Sumner 1-51/+79 2022-10-21Fix bugs in mask boolean valuesGravatar Jarred Sumner 2-15/+21 2022-10-21Emit errorsGravatar Jarred Sumner 2-2/+37 2022-10-21Add test for ResolveError.position being inspectableGravatar Jarred Sumner 2-0/+12 2022-10-21Fix segfault when logging position object from failed nested importGravatar Jarred Sumner 1-114/+34 2022-10-21Implement `setMaxListeners` and `getMaxListeners`Gravatar Jarred Sumner 1-1/+46 2022-10-21Fix `import Foo, {bar}` when from hardcoded builtin modules in runtimeGravatar Jarred Sumner 2-19/+34 2022-10-21Fix test failureGravatar Jarred Sumner 1-2/+3 2022-10-21Reload node:fs in developmentGravatar Jarred Sumner 1-0/+9 2022-10-21chore: remove outdated `var` usages (#1364)Gravatar Carter Snook 1-34/+34 2022-10-21Fix "/" in exampleGravatar Jarred Sumner 1-3/+10 2022-10-21Fix infinite loopGravatar Jarred Sumner 1-3/+13 2022-10-21micro-optimizeGravatar Jarred Sumner 1-7/+14 2022-10-20Update install script to use secure flagsGravatar Ashcon Partovi 2-5/+5 2022-10-20Add installation method for HomebrewGravatar Ashcon Partovi 1-0/+7 2022-10-20Fix crash in `highWaterMark`Gravatar Jarred Sumner 1-143/+144 2022-10-20Fix Bun.serve error handler error param (#1359)Gravatar zhiyuan 7-4/+37 2022-10-19Fix calling `ws.publish` inside `close` when other clients are connectedGravatar Jarred Sumner 3-28/+111 2022-10-19Cache dir loader: Prefer `$BUN_INSTALL` and `$XDG_CACHE_HOME` to `$HOME`. (#1...Gravatar Lucas Garron 1-5/+5 2022-10-19Improve issue templates (#1353)Gravatar Ashcon Partovi 8-89/+136