Skip to content

Commit

Permalink
docs: add details to discord setup instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
viliusddd committed Jul 30, 2024
1 parent 3e003a1 commit 44feef5
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/emojis/tests/emojis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/messages/tests/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/messages/tests/service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion src/modules/praises/tests/praises.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/sprints/tests/sprints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/templates/tests/templates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/users/tests/users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 44feef5

Please sign in to comment.