Skip to content

Commit e9ba0ea

Browse files
authored
Updating CONTRIBUTING.md (#49)
* updated docs * typo fix * doc addition : volta * update contribution doc * fix typo * update doc
1 parent c4d8adc commit e9ba0ea

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

CONTRIBUTING.md

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,37 @@
55

66
## Getting Started
77

8-
To work on this project please create an account on Cloudflare and Discord.
9-
Also, create a personal discord server.
10-
Copy the guild id of your server and save it in a .env file as `DISCORD_GUILD_ID`
11-
12-
To get the server ID for the first parameter, open Discord, go to Settings > Advanced and enable developer mode.
13-
Then, right-click on the server title and select "Copy ID" to get the guild ID.
14-
8+
To contribute to this project, you have to set up few things first.
9+
10+
- Create an account on Cloudfare Workers and Discord if you don't already have one
11+
- Create a personal discord server
12+
- Fork and clone this repo (this is optional; if you are a member of RDS community, you don't have to fork)
13+
- Install volta - this will check if you have the right node version or not
14+
- Create a .env file in the root directory of the project
15+
16+
Next, you need to gather few details that will be crucial for setting up your local environment. The IDs that you will gather in the next steps, will be stored as secret keys on the Cloudfare workers platform, where the application will be hosted.
17+
18+
- To get the guild ID of your server :
19+
- Open your discord server
20+
- Click on the server name in the top-left corner
21+
- Click on Server Settings
22+
- Click on the Widget tab in the side panel
23+
- Copy/paste the Server ID in the .env file as `DISCORD_GUILD_ID`
1524
- Visit [Discord Developer Portal](https://discord.com/developers/applications)
1625
- Click on new application.
26+
- Under the General Information panel
27+
- copy/paste the Application ID in the .env file as `DISCORD_APPLICATION_ID`
28+
- copy/paste the Public Key in the .env file as `DISCORD_PUBLIC_KEY`
1729

18-
Gather the following details from the Developer portal and save it in a .env file.
30+
Next, you need to create your own bot. The idea here is that you will have your own bot that can be used to run all commands in your private server. You can add new features and test it there to make sure everything works as expected, before deploying the code on production.
1931

20-
```
21-
DISCORD_TOKEN: Available in bot panel of your discord bot after clicking reset token button.
22-
DISCORD_APPLICATION_ID: Available in general panel of your discord bot.
23-
DISCORD_PUBLIC_KEY: Available in general panel of your discord bot.
24-
```
32+
- To create a bot, go to the Bot panel and click on 'Add Bot'
33+
- Next, copy the token from the dashboard there and save it in the .env file as `DISCORD_TOKEN `.
34+
- Next, you have to generate a set of RSA keys 2048 bit in size. We will use them as `BOT_PRIVATE_KEY` and `BOT_PUBLIC_KEY`.
2535

26-
Now, generate a set of RSA keys 2048 bit in size.
27-
28-
We will use them as `BOT_PRIVATE_KEY` and `BOT_PUBLIC_KEY`
29-
30-
Please set Following permissions for your bot:
36+
- You can read more about RSA keys [here](https://www.namecheap.com/support/knowledgebase/article.aspx/798/69/what-is-an-rsa-key-used-for/)
37+
- All you need to know for now is that the private and public keys are used when authenticating using JWT.
38+
- You can generate your own keys for local development [here](https://cryptotools.net/rsagen)
3139

3240
- Navigate to OAuth2 > URL Generator
3341
- In scopes select `bot` and `applications.commands`
@@ -43,24 +51,23 @@ Please set Following permissions for your bot:
4351
- Mention Everyone
4452
- Use slash commands
4553

46-
After providing all the permissions you will get an url at the bottom of the page use that to invite the bot to your server.
54+
After providing all the permissions, a URL will be generated below.
4755

48-
Open the Url you get and invite the bot to your test server.
56+
- Copy/paste this URL in a new browser window
57+
- Select your private server from the dropdown and authorize
58+
- This will invite the bot to your private discord server
4959

5060
## Setting Up Local Development
5161

52-
- Clone the Repository to your machine
53-
- Now, get the .env file created above in the project folder
5462
- run `npm install`
55-
- Now, run the command `npm run register`
56-
57-
This will register all the commands to your discord bot.
63+
- Now, run the command `npm run register` - this will register all the commands to your discord bot.
5864

59-
Now let's link our local development server to our bot.
65+
Next you will have to set up the wrangler cli, so that you can connect to your cloudflare workers account.
6066

61-
Run the command `npx wrangler publish`
67+
- run `npx wrangler login` -> You will be prompted to authenticate your account, after which you will see a 'successfully logged in' message in your terminal
68+
- For a sanity check, run `npx wrangler whoami` -> You will then see your account name and account id in the terminal
6269

63-
- After all the commands are installed
70+
- Run the command `npx wrangler publish`
6471
- Go to Your cloudflare `dashboard > workers > discord-slash-commands > settings > variables > edit Variables`
6572
- Now add following variables to your environment:
6673

@@ -69,13 +76,12 @@ Run the command `npx wrangler publish`
6976
- `DISCORD_PUBLIC_KEY`
7077
- `DISCORD_TOKEN`
7178

72-
- Now, start the local server with the command `npm start`
73-
- Once the wrangler starts make sure it is running on port `8787`
74-
- Once the server starts on desired port open another terminal and type in the command `npm run ngrok`
75-
- The above command will give you a `https` link copy that.
79+
- Now, start the local server with the command `npm start`- make sure it is running on port `8787`
80+
- Open another terminal and type in the command `npm run ngrok`.
81+
- `ngrok` creates a secure tunnel that allows a local server to connect to external clients. It provides a URL that can be used to connect to a local server, just like if it were a public server hosted somewhere. For eg: Say you're running your app on `http://127.0.0.1:5501/` i.e localhost port 5501. Any external applications cannot connect to this server by default, but `ngrok` will give you a `http(s)` URL that any other client can use to connect to this server.
82+
- You will see 2 URLs generated, copy the `https` URL (eg: https://765m-321-132-44-44-44.ngrok.io)
7683
- Now, go to [Discord Developer Portal](https://discord.com/developers/applications) and select your bot
77-
- In general information panel you will find a space for `INTERACTIONS ENDPOINT URL`
78-
- Enter the copied link here and hit save.
84+
- In the General Information, paste the link in the `INTERACTIONS ENDPOINT URL` field.
7985

8086
To verify if your bot is working:
8187

@@ -98,6 +104,6 @@ botToken:{
98104

99105
- Go to `constants.js` in discord-slash-commands
100106
- Go to `src/constants/urls.ts`
101-
- Change the `RDS_BASE_DEVELOPMENT_API_URL` to the `ngrok https` url generated for rds backend
107+
- Change the `RDS_BASE_DEVELOPMENT_API_URL` to the `ngrok https` URL generated for rds backend
102108

103109
Now you are ready to contribute to the Repository.

0 commit comments

Comments
 (0)