Compare commits

..

3 commits

3 changed files with 21 additions and 7 deletions

View file

@ -1,6 +1,6 @@
{
"name": "muffinbot",
"version": "4.0.0-pudding.p241018a",
"version": "4.0.0-pudding.p241027a",
"main": "dist/src/index.js",
"private": true,
"dependencies": {

View file

@ -65,8 +65,13 @@ export default class MuffinBot extends SapphireClient {
}
public override async login(): Promise<string> {
if (container.channel === 'RELEASE') await container.chatBot.train(this)
else {
if (container.channel === 'RELEASE') {
if (!config.train.user_ID)
container.logger.info(
'[MuffinBot] .env파일에 TRAIN_USER_ID값이 없어서 학습 기능이 꺼졌어요.',
)
else await container.chatBot.train(this)
} else {
container.logger.info(
'[MuffinBot] 해당 채널은 RELEASE 채널이 아니라서 학습 기능이 꺼졌습니다.',
)

View file

@ -1,13 +1,22 @@
import 'dotenv/config'
function getConfigValue(
value: 'BOT_TOKEN' | 'BOT_OWNER_ID' | 'BOT_PREFIX',
) {
const configValue = process.env[value]
if (!configValue)
throw new Error(`.env 파일에서 ${value}값을 찾을 수 없어요.`)
return configValue
}
export default class MAAConfig {
public readonly bot = {
token: process.env.BOT_TOKEN!,
owner_ID: process.env.BOT_OWNER_ID!,
prefix: process.env.BOT_PREFIX!,
token: getConfigValue('BOT_TOKEN'),
owner_ID: getConfigValue('BOT_OWNER_ID'),
prefix: getConfigValue('BOT_PREFIX'),
}
public readonly train = {
user_ID: process.env.TRAIN_USER_ID!,
user_ID: process.env.TRAIN_USER_ID,
}
}