feat: Add Config.nodeEnv & Set logger level
This commit is contained in:
parent
4105645f7f
commit
1442055f41
2 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
type NodeEnv = 'development' | 'production'
|
||||
|
||||
export class Config {
|
||||
private _getRequiredValue(key: string) {
|
||||
const value = process.env[key]
|
||||
|
@ -19,4 +21,8 @@ export class Config {
|
|||
public train = {
|
||||
userId: this._getValue('TRAIN_USER_ID'),
|
||||
}
|
||||
|
||||
public nodeEnv: NodeEnv = this._getValue('NODE_ENV')
|
||||
? (this._getValue('NODE_ENV') as NodeEnv)
|
||||
: 'production'
|
||||
}
|
||||
|
|
11
src/index.ts
11
src/index.ts
|
@ -1,5 +1,5 @@
|
|||
import './init'
|
||||
import { SapphireClient } from '@sapphire/framework'
|
||||
import { LogLevel, SapphireClient } from '@sapphire/framework'
|
||||
import { container } from '@sapphire/pieces'
|
||||
import { GatewayIntentBits, Partials } from 'discord.js'
|
||||
|
||||
|
@ -17,6 +17,15 @@ const client = new SapphireClient({
|
|||
repliedUser: true,
|
||||
},
|
||||
partials: [Partials.Message, Partials.ThreadMember],
|
||||
logger: {
|
||||
level:
|
||||
container.config.nodeEnv === 'development'
|
||||
? LogLevel.Debug
|
||||
: LogLevel.Info,
|
||||
},
|
||||
})
|
||||
|
||||
client.on('debug', container.logger.debug)
|
||||
client.on('error', container.logger.error)
|
||||
|
||||
client.login(container.config.bot.token)
|
||||
|
|
Reference in a new issue