From 8d1b44a82adb071c88b67470594a77509d8843fc Mon Sep 17 00:00:00 2001 From: Migan178 Date: Tue, 31 Jan 2023 18:05:27 +0900 Subject: [PATCH] edit: db path --- example.env | 2 ++ src/ChatBot.ts | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 example.env diff --git a/example.env b/example.env new file mode 100644 index 0000000..3f96f67 --- /dev/null +++ b/example.env @@ -0,0 +1,2 @@ +DISCORD_TOKEN='BOT_TOKEN' +DB_PATH='DB_PATH' \ No newline at end of file diff --git a/src/ChatBot.ts b/src/ChatBot.ts index a00c2d1..f9c3320 100644 --- a/src/ChatBot.ts +++ b/src/ChatBot.ts @@ -1,5 +1,5 @@ import type { Client, Message } from 'discord.js' -import { join } from 'node:path' +// import { join } from 'node:path' import Database from './Database' type TrainType = 'muffinOnly' | 'All' @@ -12,18 +12,17 @@ export default class ChatBot { set trainType(value: TrainType) { this._trainType = value } - public db = new Database(join(__dirname, '..', 'db', 'db.sqlite3')) + public db = new Database(process.env.DB_PATH!) private _trainType: TrainType = 'All' - public constructor() {} public getResponse(msg: Message, sendMsg?: boolean): ChatBot { this.db .all() .then(rows => { - const a = msg.content.replace('머핀아', '') + const a = msg.content.replace('머핀아 ', '') let r = rows[Math.floor(Math.random() * rows.length)].text if (!r) r = '살ㄹ려주세요' - console.log(`⌨️ ㅣ${a}`) + console.log(`⌨️ㅣ${a}`) console.log(`🍰ㅣ${r}`) if (sendMsg) { msg.channel.sendTyping()