Skip to content

Commit

Permalink
refactor: index env vars, make discord start() private
Browse files Browse the repository at this point in the history
  • Loading branch information
viliusddd committed Jul 30, 2024
1 parent 24eb919 commit 80ef930
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import createApp from './app'
import createDB from './database'
import BotClient from './services/discord'

const {DATABASE_URL, PORT} = process.env
const {
DATABASE_URL,
PORT,
DISCORD_CHANNEL_ID,
DISCORD_GUILD_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(
process.env.DISCORD_CHANNEL_ID,
process.env.DISCORD_GUILD_ID,
process.env.DISCORD_TOKEN
)
const bot = new BotClient(DISCORD_CHANNEL_ID, DISCORD_GUILD_ID, DISCORD_TOKEN)

const db = createDB(DATABASE_URL)
const app = createApp(db, bot)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/messages/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Router} from 'express'
import {StatusCodes} from 'http-status-codes'
import type {Request, Response, NextFunction} from 'express'
import type {Database} from '@/database'
import {createRec} from './services'
import {createRec} from './service'
import {discordHandler, jsonRoute, unsupportedRoute} from '@/utils/middleware'
import {MessageNotFound} from './errors'
import {SprintNotFound} from '../sprints/errors'
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/services/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class BotClient extends Client {
this.start()
}

public start() {
private start() {
this.once(Events.ClientReady, readyClient => {
console.log(`Discord bot is ready. Logged in as ${readyClient.user.tag}.`)
})
Expand Down

0 comments on commit 80ef930

Please sign in to comment.