-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { databaseView, databaseInput } = require('../utils/db') | ||
|
||
module.exports = { | ||
name: 'notes', | ||
aliases: ['nt'], | ||
description: 'Untuk menyimpan note atau catatan di group\nPenggunaan: !notes <save/remove> <key> <value>', | ||
async execute (client, chat, pesan, args) { | ||
if (!client.isGroup) return client.reply(pesan.error.group) | ||
if (!client.isGmium) return client.reply(pesan.error.premium) | ||
if (!client.isGroupAdmins) return client.reply(pesan.hanya.admin) | ||
if (!client.isBotGroupAdmins) return client.reply(pesan.hanya.botAdmin) | ||
const key = args[1] | ||
const res = args[2] | ||
if (args == 0) { | ||
await databaseView('SELECT * FROM notes') | ||
.then((hasil) => { | ||
let text = 'Daftar *notes* di group ini\n\n' | ||
if (hasil.length > 0) { | ||
for (const list of hasil) { | ||
if (list.gid == client.groupId) { | ||
text += `- *${list.key}*` | ||
} | ||
} | ||
client.reply(text) | ||
} else { | ||
text += '_Belum ada notes_' | ||
client.reply(text) | ||
} | ||
}) | ||
} else if (args > 0 && args[0] == 'save') { | ||
databaseInput(`INSERT INTO notes(gid, key, res) VALUES ('${client.groupId}', '#${key}', '${res}')`) | ||
.then(() => client.reply('Berhasil menambahkan notes')) | ||
} else if (args > 0 && args[0] == 'remove') { | ||
databaseInput(`DELETE FROM notes WHERE key = ${key} AND gid = ${client.groupId}`) | ||
.then(() => client.reply(`Berhasil menghapus notes #${key}`)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters