From 44feef5053009700eacb64ab529ab21e1f3223d8 Mon Sep 17 00:00:00 2001 From: Vilius Date: Tue, 30 Jul 2024 16:51:58 +0300 Subject: [PATCH] docs: add details to discord setup instruction --- .github/workflows/deploy.yaml | 2 +- README.md | 20 +++++++++++++------ environment.d.ts | 2 +- src/index.ts | 4 ++-- src/modules/emojis/tests/emojis.spec.ts | 2 +- src/modules/messages/tests/messages.spec.ts | 2 +- src/modules/messages/tests/service.spec.ts | 2 +- src/modules/praises/tests/praises.spec.ts | 2 +- src/modules/sprints/tests/sprints.spec.ts | 2 +- src/modules/templates/tests/templates.spec.ts | 2 +- src/modules/users/tests/users.spec.ts | 2 +- 11 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a965858..29bc404 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -34,5 +34,5 @@ jobs: PORT: ${{ vars.PORT }} DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} DISCORD_CHANNEL_ID: ${{ secrets.DISCORD_CHANNEL_ID }} - DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }} + DISCORD_SERVER_ID: ${{ secrets.DISCORD_SERVER_ID }} GIPHY_API_KEY: ${{ secrets.GIPHY_API_KEY }} diff --git a/README.md b/README.md index 48bf5a8..7c53db4 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,20 @@ It's a dynamic Discord bot powered by a REST API that celebrates user achievemen ## Discord Setup -1. Create new Application at https://discord.com/developers/applications -2. Go to your newly created application -\> OAuth2 -\> `Reset Secret` to get new token. -3. Copy & rename `.env.example` to `.env` -4. Paste yur app token to the `.env` and fill in the rest of the variables. -5. Enable `GUILD_MEMBERS` intent: - - Ensure your bot has the GUILD_MEMBERS intent enabled in the Discord Developer Portal and in your code. +1. Create a copy of `.env.example` and rename it to `.env` +2. Fill-in `DISCORD_SERVER_ID`, `DISCORD_CHANNEL_ID` variables. +3. Get giphy api key from [here](https://developers.giphy.com/dashboard/?create=true) +4. Create new Discord bot Application at https://discord.com/developers/applications +5. On the left-side meniu go to `Bot` and: + 1. enable `SERVER MEMBERS INTENT` + 2. enable `MESSAGE CONTENT INTENT` + 3. press `Reset Token`, then add it to `.env`, `DISCORD_TOKEN` +6. On the left-side menu, go to `OAuth` and, under `OAuth2 URL Generator`: + 1. choose `bot` + 2. choose `applications.commands` + 3. at the bottom, under `GENERATED URL` press copy (is should look similar to `https://discord.com/oauth2/authorize?client_id=1267831555741581382&permissions=0&integration_type=0&scope=bot`) + 4. paste copied url at you internet browser, choose channel you want your bot to reside. +7. Paste yur app token to the `.env` and fill in the rest of the variables. ## Project Setup diff --git a/environment.d.ts b/environment.d.ts index e77ba9f..2c657c2 100644 --- a/environment.d.ts +++ b/environment.d.ts @@ -5,7 +5,7 @@ declare namespace NodeJS { PORT: string DISCORD_TOKEN: string DISCORD_CHANNEL_ID: string - DISCORD_GUILD_ID: string + DISCORD_SERVER_ID: string GIPHY_API_KEY: string } } diff --git a/src/index.ts b/src/index.ts index 20b840b..a047975 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,14 +7,14 @@ const { DATABASE_URL, PORT, DISCORD_CHANNEL_ID, - DISCORD_GUILD_ID, + DISCORD_SERVER_ID, DISCORD_TOKEN } = process.env if (!DATABASE_URL) throw new Error('Provide DATABASE_URL in your env variable.') if (!PORT) throw new Error('Provide PORT in your env variable.') -const bot = new BotClient(DISCORD_CHANNEL_ID, DISCORD_GUILD_ID, DISCORD_TOKEN) +const bot = new BotClient(DISCORD_CHANNEL_ID, DISCORD_SERVER_ID, DISCORD_TOKEN) const db = createDB(DATABASE_URL) const app = createApp(db, bot) diff --git a/src/modules/emojis/tests/emojis.spec.ts b/src/modules/emojis/tests/emojis.spec.ts index 47d07b4..54e2232 100644 --- a/src/modules/emojis/tests/emojis.spec.ts +++ b/src/modules/emojis/tests/emojis.spec.ts @@ -8,7 +8,7 @@ import BotClient from '@/services/discord' const bot = new BotClient( process.env.DISCORD_CHANNEL_ID, - process.env.DISCORD_GUILD_ID, + process.env.DISCORD_SERVER_ID, process.env.DISCORD_TOKEN ) const db = await createTestDatabase() diff --git a/src/modules/messages/tests/messages.spec.ts b/src/modules/messages/tests/messages.spec.ts index 08ecea9..530b861 100644 --- a/src/modules/messages/tests/messages.spec.ts +++ b/src/modules/messages/tests/messages.spec.ts @@ -13,7 +13,7 @@ import createApp from '@/app' const bot = new BotClient( process.env.DISCORD_CHANNEL_ID, - process.env.DISCORD_GUILD_ID, + process.env.DISCORD_SERVER_ID, process.env.DISCORD_TOKEN ) const db = await createTestDatabase() diff --git a/src/modules/messages/tests/service.spec.ts b/src/modules/messages/tests/service.spec.ts index 9a8ae86..22242f2 100644 --- a/src/modules/messages/tests/service.spec.ts +++ b/src/modules/messages/tests/service.spec.ts @@ -12,7 +12,7 @@ import {apiMessageMatcher} from './utils' const db = await createTestDatabase() const bot = new BotClient( process.env.DISCORD_CHANNEL_ID, - process.env.DISCORD_GUILD_ID, + process.env.DISCORD_SERVER_ID, process.env.DISCORD_TOKEN ) diff --git a/src/modules/praises/tests/praises.spec.ts b/src/modules/praises/tests/praises.spec.ts index 559bf58..31f2b06 100644 --- a/src/modules/praises/tests/praises.spec.ts +++ b/src/modules/praises/tests/praises.spec.ts @@ -8,7 +8,7 @@ import BotClient from '@/services/discord' const bot = new BotClient( process.env.DISCORD_CHANNEL_ID, - process.env.DISCORD_GUILD_ID, + process.env.DISCORD_SERVER_ID, process.env.DISCORD_TOKEN ) const db = await createTestDatabase() diff --git a/src/modules/sprints/tests/sprints.spec.ts b/src/modules/sprints/tests/sprints.spec.ts index df18fa0..d9c42d2 100644 --- a/src/modules/sprints/tests/sprints.spec.ts +++ b/src/modules/sprints/tests/sprints.spec.ts @@ -8,7 +8,7 @@ import BotClient from '@/services/discord' const bot = new BotClient( process.env.DISCORD_CHANNEL_ID, - process.env.DISCORD_GUILD_ID, + process.env.DISCORD_SERVER_ID, process.env.DISCORD_TOKEN ) const db = await createTestDatabase() diff --git a/src/modules/templates/tests/templates.spec.ts b/src/modules/templates/tests/templates.spec.ts index 4f0465a..8beb975 100644 --- a/src/modules/templates/tests/templates.spec.ts +++ b/src/modules/templates/tests/templates.spec.ts @@ -8,7 +8,7 @@ import BotClient from '@/services/discord' const bot = new BotClient( process.env.DISCORD_CHANNEL_ID, - process.env.DISCORD_GUILD_ID, + process.env.DISCORD_SERVER_ID, process.env.DISCORD_TOKEN ) const db = await createTestDatabase() diff --git a/src/modules/users/tests/users.spec.ts b/src/modules/users/tests/users.spec.ts index 4c46506..aad7484 100644 --- a/src/modules/users/tests/users.spec.ts +++ b/src/modules/users/tests/users.spec.ts @@ -8,7 +8,7 @@ import BotClient from '@/services/discord' const bot = new BotClient( process.env.DISCORD_CHANNEL_ID, - process.env.DISCORD_GUILD_ID, + process.env.DISCORD_SERVER_ID, process.env.DISCORD_TOKEN ) const db = await createTestDatabase()