feat: Add Config.nodeEnv & Set logger level

This commit is contained in:
Siwoo Jeon 2025-02-23 18:10:55 +09:00
parent 4105645f7f
commit 1442055f41
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
2 changed files with 16 additions and 1 deletions

View file

@ -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'
}

View file

@ -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)