Files
discordeno/website/docs/examples/bun.md
Fleny 43d52a6c43 docs: Add examples for Node.js and Bun, update Deno example (#3385)
* Update docusaurus typescript setup for v3

And fix lint-staged and eslint

* Enable automatic JSX runtime

* Remove babel config and dependencies

* update yarn.lock

* add typecheck to site workflow

* update typedoc config

* downgrade docusaurus packages

* Update site.yml

* Type context and options in webpack-docusaurus-plugin.ts

* Update env tips and add minimal examples for node and bun

And update the one from deno that was really out of date

---------

Co-authored-by: Matt Hatcher <3768988+MatthewSH@users.noreply.github.com>
2024-02-25 01:41:44 +00:00

41 lines
1.2 KiB
Markdown

---
sidebar_position: 4
sidebar_label: Using with Bun
---
# Using with Bun
Discordeno supports Bun by installing the `@discordeno/bot` package
## Pre-Requirements
Before, going forward, please make sure to have finished everything on this list.
- Create an application and get the bot token. [Create Application Guide](https://discordeno.js.org/docs/beginner/token)
- Add your bot to a server you own. [Invite Bot Guide](https://discordeno.js.org/docs/beginner/inviting)
- Install Discordeno. [Installation Guide](https://discordeno.js.org)
- Setup environment variables. [Environment Variables Guide](https://discordeno.js.org/docs/beginner/env)
After you installed the `@discordeno/bot` package with bun you can start using it.
This is how you can use it to create a bot that logs into discord:
```ts
import { createBot } from '@discordeno/bot'
const bot = createBot({
token: Bun.env.token,
events: {
ready: ({ shardId }) => console.log(`Shard ${shardId} ready`),
},
})
await bot.start()
```
:::note
If you want you can use bun with any package manager, so if you want to can use npm to install the `node_modules` and use bun to run the code
:::
You are free to expand from this point with whatever code you want. Happy coding!