You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+41-35Lines changed: 41 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,29 +5,37 @@
5
5
6
6
## Getting Started
7
7
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`
- 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`
17
29
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.
19
31
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`.
25
35
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)
31
39
32
40
- Navigate to OAuth2 > URL Generator
33
41
- In scopes select `bot` and `applications.commands`
@@ -43,24 +51,23 @@ Please set Following permissions for your bot:
43
51
- Mention Everyone
44
52
- Use slash commands
45
53
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.
47
55
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
49
59
50
60
## Setting Up Local Development
51
61
52
-
- Clone the Repository to your machine
53
-
- Now, get the .env file created above in the project folder
54
62
- 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.
58
64
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.
60
66
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
62
69
63
-
-After all the commands are installed
70
+
-Run the command `npx wrangler publish`
64
71
- Go to Your cloudflare `dashboard > workers > discord-slash-commands > settings > variables > edit Variables`
65
72
- Now add following variables to your environment:
66
73
@@ -69,13 +76,12 @@ Run the command `npx wrangler publish`
69
76
-`DISCORD_PUBLIC_KEY`
70
77
-`DISCORD_TOKEN`
71
78
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)
76
83
- 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.
79
85
80
86
To verify if your bot is working:
81
87
@@ -98,6 +104,6 @@ botToken:{
98
104
99
105
- Go to `constants.js` in discord-slash-commands
100
106
- 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
102
108
103
109
Now you are ready to contribute to the Repository.
0 commit comments