-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Utilise create-discord-bot (#10013)
* feat: utilise create-discord-bot * chore: hide line numbers * feat: add intents page * feat: add more Node.js variants * refactor: redo page a bit * fix: 👀 * chore: touch up introduction page * chore: touch up what's new * chore: touch up how to contribute * chore: remove enforced locale * chore: Fix typo Co-authored-by: Danial Raza <danialrazafb@gmail.com> * chore: commit suggestions Co-authored-by: Souji <timoqueezle@gmail.com> * chore: address improper capitalisation Co-authored-by: Souji <timoqueezle@gmail.com> * refactor: remove `applications.commands` * refactor: remove unique comment * fix(intents): remove shard comment * docs(intents): add missing info --------- Co-authored-by: Danial Raza <danialrazafb@gmail.com> Co-authored-by: Souji <timoqueezle@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
adfd9cd
commit 18c2dcc
Showing
30 changed files
with
225 additions
and
1,261 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
apps/guide/src/content/02-getting-started/01-starting-out.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Starting out | ||
category: Getting started | ||
--- | ||
|
||
# Starting out | ||
|
||
Our [create-discord-bot](https://github.com/discordjs/discord.js/tree/main/packages/create-discord-bot) command-line interface sets up a basic Discord bot to help you get started on your journey. | ||
|
||
## Creating your bot | ||
|
||
To use discord.js, you'll need to install [Node.js](https://nodejs.org), [Deno](https://deno.com), or [Bun](https://bun.sh). discord.js v14 requires Node.js v16.11.0 or higher, but the long-term support (LTS) version is always recommended. For the purposes of this guide, we will be using Node.js. | ||
|
||
<Alert title="Tip" type="info"> | ||
To check if you already have Node.js installed, run _`node --version`_ in your terminal. If it outputs _`v16.11.0`_ or | ||
higher, then you're good to go! | ||
</Alert> | ||
|
||
### Windows | ||
|
||
- Download from the [Node.js website](https://nodejs.org). | ||
- Use [fnm](https://github.com/Schniz/fnm). | ||
- Use [Volta](https://volta.sh). | ||
|
||
### macOS | ||
|
||
- Download from the [Node.js website](https://nodejs.org/). | ||
- Use [fnm](https://github.com/Schniz/fnm). | ||
- Use [Homebrew](https://formulae.brew.sh/formula/node). | ||
- Use [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating). | ||
- Use [Volta](https://volta.sh). | ||
|
||
### Linux | ||
|
||
- Visit [this page](https://nodejs.org/en/download/package-manager) to determine how you should install Node.js. | ||
- Use [fnm](https://github.com/Schniz/fnm). | ||
- Use [nvm](https://github.com/nvm-sh/nvm). | ||
- Use [Volta](https://volta.sh). | ||
|
||
After installing Node.js, you'll be able to create a new application from your desired package manager. If you're starting out fresh, installing Node.js will also install npm, a package manager for Node.js. | ||
|
||
<CH.Code lineNumbers={false} showCopyButton={true}> | ||
|
||
```sh npm | ||
npm create discord-bot | ||
``` | ||
|
||
```sh yarn | ||
yarn create discord-bot | ||
``` | ||
|
||
```sh pnpm | ||
pnpm create discord-bot | ||
``` | ||
|
||
```sh bun | ||
bun create discord-bot | ||
``` | ||
|
||
</CH.Code> | ||
|
||
You'll be asked the directory to create the application in, as well as whether TypeScript should be used. Dependencies will automatically be installed for you. After this, you've just got your startup Discord bot template _nearly_ ready! | ||
|
||
In the next section, we will explain how to create an application to interact with Discord's API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
apps/guide/src/content/02-getting-started/03-adding-your-bot-to-a-server.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: Adding your bot to a server | ||
category: Getting started | ||
--- | ||
|
||
# Adding your bot to a server | ||
|
||
After you [set up an application](./setting-up-an-application), you'll notice it's not in any servers yet. So, how does that work? | ||
|
||
Before you're able to see your bot in a server, you will need to add it by using an invite link. | ||
|
||
## Bot invite links | ||
|
||
The basic version of one such link looks like this: | ||
|
||
<CH.Code lineNumbers={false}> | ||
|
||
``` | ||
https://discord.com/api/oauth2/authorize?client_id=123456789012345678&permissions=0&scope=bot | ||
``` | ||
|
||
</CH.Code> | ||
|
||
The structure of the URL is quite simple: | ||
|
||
- _`https://discord.com/api/oauth2/authorize`_ is Discord's standard structure for authorizing an OAuth2 application (such as your bot application) for entry to a Discord server. | ||
- _`client_id=...`_ is to specify _which_ application you want to authorize. You'll need to replace this part with your client's id to create a valid invite link. | ||
- _`permissions=...`_ describes the permissions that your bot will request to be granted by default upon joining the server you are adding it to. | ||
- _`scope=bot`_ specifies that you want to add this application as a Discord bot with the ability to create slash commands. | ||
|
||
<Alert title="Warning" type="warning"> | ||
If you get an error message saying "Bot requires a code grant", head over to your application's settings and disable | ||
the "Requires OAuth2 Code Grant" option. You shouldn't enable this option unless you know why you need to. | ||
</Alert> | ||
|
||
## Creating and using your invite link | ||
|
||
To create an invite link, head back to the [developer portal](https://discord.com/developers/applications), click on your bot application, and open the OAuth2 page. | ||
|
||
In the sidebar, you'll find the URL generator. Select the _`bot`_ option. Once you select the _`bot`_ option, a list of permissions will appear, allowing you to configure the permissions your bot needs. | ||
|
||
Grab the link via the "Copy" button and send it in a channel in Discord. Click on the link you just sent which should reveal this: | ||
|
||
![Bot Authorization page](/assets/bot-auth-page.png) | ||
|
||
Choose the server you want to add the bot to and click "Authorize". Congratulations! You've successfully added your bot to your Discord server. | ||
|
||
At this point, you should have a Discord bot you created with [create-discord-bot](https://github.com/discordjs/discord.js/tree/main/packages/create-discord-bot) with your .env file populated and your Discord bot in a server. You are now ready to do what you like. |
110 changes: 0 additions & 110 deletions
110
.../src/content/02-installations-and-preparations/01-installing-node-discordjs.mdx
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
.../guide/src/content/02-installations-and-preparations/02-setting-up-a-linter.mdx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
18c2dcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
discord-js-guide – ./apps/guide
discord-js-guide-discordjs.vercel.app
discord-js-guide.vercel.app
discord-js-guide-git-main-discordjs.vercel.app
guide.discordjs.dev
next.discordjs.guide