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.
span>/+5 2022-03-17Update lockfile.zigGravatar Jarred Sumner 1-0/+16 2022-03-17Move `Bun` to JSC.APIGravatar Jarred Sumner 8-1420/+1667 2022-03-17lil helper methodGravatar Jarred Sumner 1-0/+8 2022-03-17Update build-idGravatar Jarred Sumner 1-1/+1 2022-03-17only check oncebun-v0.0.73Gravatar Jarred Sumner 1-42/+33 2022-03-17Add test coverage for emoji in blobsGravatar Jarred Sumner 1-84/+133 2022-03-17Prevent segfaultGravatar Jarred Sumner 1-0/+4 2022-03-17move some code aroundGravatar Jarred Sumner 3-189/+9 2022-03-17Update build-idGravatar Jarred Sumner 1-1/+1 2022-03-17optimize blob.text()Gravatar Jarred Sumner 1-83/+185 2022-03-17query_string_map -> urlGravatar Jarred Sumner 30-28/+405 2022-03-16Fix crash from checking if something is an object when it is undefinedbun-v0.0.72Gravatar Jarred Sumner 4-12/+12 2022-03-16Fix setTimeout on LinuxGravatar Jarred SUmner 1-5/+12 2022-03-16Increase from 4ms -> 40ms for timeoutGravatar Jarred SUmner 1-1/+1 2022-03-16Update README.mdGravatar Jarred Sumner 1-0/+1 2022-03-16llvm-stirp not workingGravatar Jarred Sumner 1-1/+0 2022-03-16Update MakefileGravatar Jarred Sumner 1-1/+1 2022-03-16Update Dockerfile.baseGravatar Jarred Sumner 1-0/+1 2022-03-16Update MakefileGravatar Jarred Sumner 1-2/+23 2022-03-16cleanup error printingGravatar Jarred Sumner 7-105/+193 2022-03-16Revert "Unlimited arguments in process.nextTick"Gravatar Jarred Sumner 1-38/+48 2022-03-16bun.lockbGravatar Jarred Sumner 3-0/+0 2022-03-16Update feature_flags.zigGravatar Jarred Sumner 1-0/+1 2022-03-16[bun.js] Bun.unsafe test should check the gcGravatar Jarred Sumner 1-4/+14 2022-03-16Update work_pool.zigGravatar Jarred Sumner 1-21/+28 2022-03-16Add a way to run serial tasks on a different threadGravatar Jarred Sumner 1-3/+65 2022-03-16fix crash when SyntaxError is thrown and we did not receive an ErrorInstance?Gravatar Jarred Sumner 1-18/+25 2022-03-16[bun.js] Fix release-mode test failures in HeadersGravatar Jarred Sumner 1-47/+42 2022-03-16Update ref_count.zigGravatar Jarred Sumner 1-2/+0 2022-03-15file is too bigjarred/replGravatar Jarred Sumner 1-113827/+0 2022-03-15Update Dockerfile.baseGravatar Jarred Sumner 1-1/+1 2022-03-15Add rust and lolhtml to dockerfileGravatar Jarred Sumner 2-0/+20 2022-03-15bump webkitGravatar Jarred Sumner 1-1/+1 2022-03-15Update WebKitGravatar Jarred Sumner 1-0/+0 2022-03-15:camera:Gravatar Jarred Sumner 60-799/+859 2022-03-15Fix test failureGravatar Jarred Sumner 1-15/+17 2022-03-15[bun:error] handle errors without a name or messageGravatar Jarred Sumner 1-6/+11 2022-03-15Update pool.zigGravatar Jarred Sumner 1-0/+1 2022-03-15Load .env by defaultGravatar Jarred Sumner 2-0/+8 2022-03-15mimalloc interpose is buggyGravatar Jarred Sumner 1-2/+25 2022-03-15higher max http requests for bun.jsGravatar Jarred Sumner 1-0/+29 2022-03-15zero copyGravatar Jarred Sumner 1-21/+15 2022-03-15Update javascript.zigGravatar Jarred Sumner 1-2/+0 2022-03-15[bun.js] utf8 console.{time, count, timeEnd, profile, profileEnd, count, cou...Gravatar Jarred Sumner 1-16/+16