Compare commits

...

3 commits

5 changed files with 23 additions and 16 deletions

View file

@ -17,14 +17,7 @@ const compat = new FlatCompat({
export default [ export default [
{ {
ignores: [ ignores: ['**/dist/', '**/.vscode/', '**/.idea/', '**/node_modules/'],
'**/.yarn/',
'**/.pnp.*',
'**/dist/',
'**/.vscode/',
'**/.idea/',
'**/tsup.config.ts',
],
}, },
...compat.extends('plugin:@typescript-eslint/recommended', 'prettier'), ...compat.extends('plugin:@typescript-eslint/recommended', 'prettier'),
{ {

View file

@ -1,5 +1,5 @@
{ {
"ext": "ts,json", "ext": "ts,json",
"exec": "pnpm build --sourcemap && node dist/src", "exec": "tsc --sourcemap && cross-env NODE_ENV=development node --enable-source-maps dist/src",
"ignore": ["dist/**/*.*"] "ignore": ["dist/**/*.*"]
} }

View file

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

View file

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

View file

@ -1,13 +1,22 @@
import 'dotenv/config' 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 { export default class MAAConfig {
public readonly bot = { public readonly bot = {
token: process.env.BOT_TOKEN!, token: getConfigValue('BOT_TOKEN'),
owner_ID: process.env.BOT_OWNER_ID!, owner_ID: getConfigValue('BOT_OWNER_ID'),
prefix: process.env.BOT_PREFIX!, prefix: getConfigValue('BOT_PREFIX'),
} }
public readonly train = { public readonly train = {
user_ID: process.env.TRAIN_USER_ID!, user_ID: process.env.TRAIN_USER_ID,
} }
} }