From 057e1b7c5ab07818813fee9d0b4e5009baebdd6c Mon Sep 17 00:00:00 2001 From: Kry9toN Date: Wed, 27 Jan 2021 19:12:50 +0700 Subject: [PATCH] fix notes amd add dotenv --- package.json | 1 + src/command/notes.ts | 11 ++++++----- src/krypton.ts | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7c1e34e..90a04f4 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "chalk": "^4.1.0", "child_process": "^1.0.2", "discord.js": "^12.5.1", + "dotenv": "^8.2.0", "ejs": "^3.1.5", "express": "^4.17.1", "fluent-ffmpeg": "^2.1.2", diff --git a/src/command/notes.ts b/src/command/notes.ts index 32d26e1..1692f74 100644 --- a/src/command/notes.ts +++ b/src/command/notes.ts @@ -10,9 +10,7 @@ module.exports = { if (!client.isGmium) return client.reply(pesan.hanya.premium) if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) - const arg = client.body.slice(6) - const key = arg.split('|')[1].trim() - const res = arg.split('|')[2].trim() + const arg = client.body.slice(7) if (args == 0) { await databaseView('SELECT * FROM notes') .then((hasil: any) => { @@ -29,10 +27,13 @@ module.exports = { client.reply(text) } }) - } else if (args > 0 && arg.split('|')[0].trim() == 'save') { + } else if (arg.split('|')[0].trim() == 'save') { + const key = arg.split('|')[1] + const res = arg.split('|')[2] databaseInput(`INSERT INTO notes(gid, key, res) VALUES ('${client.groupId}', '#${key}', '${res}')`) .then(() => client.reply('Berhasil menambahkan notes')) - } else if (args > 0 && arg.split('|')[0].trim() == 'remove') { + } else if (arg.split('|')[0].trim() == 'remove') { + const key = arg.split('|')[1].trim() databaseInput(`DELETE FROM notes WHERE key = ${key} AND gid = ${client.groupId}`) .then(() => client.reply(`Berhasil menghapus notes #${key}`)) } diff --git a/src/krypton.ts b/src/krypton.ts index c2b725f..5af4d38 100644 --- a/src/krypton.ts +++ b/src/krypton.ts @@ -12,6 +12,7 @@ const moment = require('moment-timezone') const { welcome, goodbye } = require('./utils/greeting') const { databaseView, databaseInput } = require('./utils/db') const { web, loging } = require('./utils/web') +require('dotenv').config() async function krypton () { const client = new WAConnection()