From 0fedec95d198e5ca1ed9ec2345114d786130e1aa Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Tue, 22 Aug 2023 19:07:32 -0700 Subject: [PATCH] feat: support bun in create-discord-bot --- .../01-installing-node-discordjs.mdx | 8 ++++++++ .../03-creating-your-bot/01-configuration-files.mdx | 4 ++++ .../content/05-additional-info/03-updating-to-v14.mdx | 4 ++++ packages/create-discord-bot/README.md | 9 ++++++++- .../create-discord-bot/src/helpers/packageManager.ts | 4 ++++ packages/discord.js/README.md | 2 ++ packages/formatters/README.md | 1 + packages/next/README.md | 1 + packages/proxy/README.md | 1 + packages/rest/README.md | 2 ++ packages/util/README.md | 1 + packages/voice/README.md | 1 + packages/ws/README.md | 1 + 13 files changed, 38 insertions(+), 1 deletion(-) diff --git a/apps/guide/src/content/02-installations-and-preparations/01-installing-node-discordjs.mdx b/apps/guide/src/content/02-installations-and-preparations/01-installing-node-discordjs.mdx index ee1657f08c14..af08606fc9d7 100644 --- a/apps/guide/src/content/02-installations-and-preparations/01-installing-node-discordjs.mdx +++ b/apps/guide/src/content/02-installations-and-preparations/01-installing-node-discordjs.mdx @@ -67,6 +67,10 @@ yarn init pnpm init; pnpm pkg set type="module" ``` +```sh bun +bun init +``` + This is the next command you'll be running. This command creates a _`package.json`_ file for you, which will keep track of the dependencies your project uses, as well as other info. @@ -93,6 +97,10 @@ yarn add discord.js pnpm add discord.js ``` +```sh bun +bun add discord.js +``` + And that's it! With all the necessities installed, you're almost ready to start coding your bot. diff --git a/apps/guide/src/content/03-creating-your-bot/01-configuration-files.mdx b/apps/guide/src/content/03-creating-your-bot/01-configuration-files.mdx index 8f0f0ca9d906..e164c71fe5bd 100644 --- a/apps/guide/src/content/03-creating-your-bot/01-configuration-files.mdx +++ b/apps/guide/src/content/03-creating-your-bot/01-configuration-files.mdx @@ -77,6 +77,10 @@ yarn add dotenv pnpm add dotenv ``` +```sh bun +# Bun automatically reads .env files +``` + diff --git a/apps/guide/src/content/05-additional-info/03-updating-to-v14.mdx b/apps/guide/src/content/05-additional-info/03-updating-to-v14.mdx index dc95ae2eaf9a..1b55a545bf60 100644 --- a/apps/guide/src/content/05-additional-info/03-updating-to-v14.mdx +++ b/apps/guide/src/content/05-additional-info/03-updating-to-v14.mdx @@ -27,6 +27,10 @@ yarn remove @discordjs/builders @discordjs/formatters @discordjs/rest discord-ap pnpm remove @discordjs/builders @discordjs/formatters @discordjs/rest discord-api-types ``` +```sh bun +bun remove @discordjs/builders @discordjs/formatters @discordjs/rest discord-api-types +``` + ## Breaking Changes diff --git a/packages/create-discord-bot/README.md b/packages/create-discord-bot/README.md index e14603e4d810..c62de56672ab 100644 --- a/packages/create-discord-bot/README.md +++ b/packages/create-discord-bot/README.md @@ -16,7 +16,14 @@ ## About -`npx create-discord-bot ./your/chosen/directory/`. It's as easy as that to create a simple Discord bot to begin your journey with the Discord API. +It's easy to create a simple Discord bot to begin your journey with the Discord API. + +```sh +npm create discord-bot ./your/chosen/directory +yarn create discord-bot ./your/chosen/directory +pnpm create discord-bot ./your/chosen/directory +bunx create-discord-bot ./your/chosen/directory +``` ## Links diff --git a/packages/create-discord-bot/src/helpers/packageManager.ts b/packages/create-discord-bot/src/helpers/packageManager.ts index c103e86b0a83..0a9731a018a6 100644 --- a/packages/create-discord-bot/src/helpers/packageManager.ts +++ b/packages/create-discord-bot/src/helpers/packageManager.ts @@ -31,6 +31,10 @@ export function resolvePackageManager(): PackageManager { return 'pnpm'; } + if (npmConfigUserAgent.startsWith('bun')) { + return 'bun'; + } + console.error( yellow( `Detected an unsupported package manager (${npmConfigUserAgent}). Falling back to ${DEFAULT_PACKAGE_MANAGER}.`, diff --git a/packages/discord.js/README.md b/packages/discord.js/README.md index 377d40c4dd79..d7eb0726c9e1 100644 --- a/packages/discord.js/README.md +++ b/packages/discord.js/README.md @@ -35,6 +35,7 @@ discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to npm install discord.js yarn add discord.js pnpm add discord.js +bun add discord.js ``` ### Optional packages @@ -52,6 +53,7 @@ Install discord.js: npm install discord.js yarn add discord.js pnpm add discord.js +bun add discord.js ``` Register a slash command against the Discord API: diff --git a/packages/formatters/README.md b/packages/formatters/README.md index b846625ac635..65ad4b0d0e99 100644 --- a/packages/formatters/README.md +++ b/packages/formatters/README.md @@ -29,6 +29,7 @@ npm install @discordjs/formatters yarn add @discordjs/formatters pnpm add @discordjs/formatters +bun add @discordjs/formatters ``` ## Example usage diff --git a/packages/next/README.md b/packages/next/README.md index dd1fa4f3cfa4..f4439e904208 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -22,6 +22,7 @@ npm install @discordjs/next yarn add @discordjs/next pnpm add @discordjs/next +bun add @discordjs/next ``` ## Links diff --git a/packages/proxy/README.md b/packages/proxy/README.md index a8e863e7222a..63eac66bfdeb 100644 --- a/packages/proxy/README.md +++ b/packages/proxy/README.md @@ -29,6 +29,7 @@ npm install @discordjs/proxy yarn add @discordjs/proxy pnpm add @discordjs/proxy +bun add @discordjs/proxy ``` ## Links diff --git a/packages/rest/README.md b/packages/rest/README.md index 243b28ccb83c..6cc1e758cd6d 100644 --- a/packages/rest/README.md +++ b/packages/rest/README.md @@ -31,6 +31,7 @@ Note: native fetch (not recommended) is unavailable in this node version, either npm install @discordjs/rest yarn add @discordjs/rest pnpm add @discordjs/rest +bun add @discordjs/rest ``` ## Examples @@ -41,6 +42,7 @@ Install all required dependencies: npm install @discordjs/rest discord-api-types yarn add @discordjs/rest discord-api-types pnpm add @discordjs/rest discord-api-types +bun add @discordjs/rest discord-api-types ``` Send a basic message: diff --git a/packages/util/README.md b/packages/util/README.md index 999ae8909425..bcdbc4ce19b7 100644 --- a/packages/util/README.md +++ b/packages/util/README.md @@ -26,6 +26,7 @@ npm install @discordjs/util yarn add @discordjs/util pnpm add @discordjs/util +bun add @discordjs/util ``` ## Links diff --git a/packages/voice/README.md b/packages/voice/README.md index 69b5012e4601..3a2c4e3a2f13 100644 --- a/packages/voice/README.md +++ b/packages/voice/README.md @@ -38,6 +38,7 @@ npm install @discordjs/voice yarn add @discordjs/voice pnpm add @discordjs/voice +bun add @discordjs/voice ``` ## Dependencies diff --git a/packages/ws/README.md b/packages/ws/README.md index b75c1b228ec3..5db86a03009c 100644 --- a/packages/ws/README.md +++ b/packages/ws/README.md @@ -29,6 +29,7 @@ npm install @discordjs/ws yarn add @discordjs/ws pnpm add @discordjs/ws +bun add @discordjs/ws ``` ### Optional packages