diff --git a/README.md b/README.md index 242e6e4..eff224d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # KryPtoN Whatsapp Bot [![DeepScan grade](https://deepscan.io/api/teams/11540/projects/14446/branches/269535/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=11540&pid=14446&bid=269535) -[![Version](https://img.shields.io/badge/version%20K--wa%20Bot-v2.8.8-brightgreen)](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/releases) +[![Version](https://img.shields.io/badge/version%20K--wa%20Bot-v0.0.1-brightgreen)](https://github.com/Kry9toN/KryPtoN-WhatsApp-Bot/releases) [![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) diff --git a/command/help.js b/command/help.js index e31f3ce..d7a285c 100644 --- a/command/help.js +++ b/command/help.js @@ -3,7 +3,7 @@ const { MessageType } = require('@adiwajshing/baileys') module.exports = { name: 'help', aliases: ['h'], - description: 'Display all commands and descriptions', + description: 'Menampilkan semua perintah dan deskripsi', execute (client, from) { const commands = client.cmd.array() let text = 'Command di bot ini\n\nPrefix: !\n' diff --git a/command/ping.js b/command/ping.js index 292da0d..bef0542 100644 --- a/command/ping.js +++ b/command/ping.js @@ -1,10 +1,12 @@ const { MessageType } = require('@adiwajshing/baileys') +const moment = require('moment-timezone') +const { processTime } = require('../utils/functions') module.exports = { name: 'ping', cooldown: 10, - description: "Show the bot's average ping", + description: 'Menampilkan rata-rata bot merespon', execute (client, from) { - client.sendMessage(from, 'oe', MessageType.text).catch(console.error) + client.sendMessage(from, `Pong!!\n${processTime(client.pingStart, moment())} _detik_`, MessageType.text).catch(console.error) } } diff --git a/krypton.js b/krypton.js index a755a10..a3ae54b 100644 --- a/krypton.js +++ b/krypton.js @@ -22,20 +22,21 @@ async function krypton () { if (fs.existsSync('./sessions/krypton-sessions.json')) { await client.loadAuthInfo('./sessions/krypton-sessions.json') await client.on('connecting', () => { - start('1', ' [SERVER] Connecting to exist sessions...') + start('1', '[SERVER] Menyambungkan ke sessions yang sudah ada...') }) } // Server connecting if (!fs.existsSync('./sessions/krypton-sessions.json')) { await client.on('connecting', () => { - start('1', ' [SERVER] Waitting scan QR to connecting...') + start('1', '[SERVER] Menunggu scan code QR untuk menyambungkan...') }) } // Server connected await client.on('open', () => { - success('1', ' [SERVER] Connected') + success('1', '[SERVER] Terhubung') + console.log('🤖',color('KryPtoN Bot Sudah siap!!', 'green')) }) // Create file for sessions @@ -43,11 +44,12 @@ async function krypton () { fs.writeFileSync('./sessions/krypton-sessions.json', JSON.stringify(client.base64EncodedAuthInfo(), null, '\t')) await client.on('chat-update', async (chat) => { + client.pingStart = Date.now() if (!chat.hasNewMessage) return const prefix = '!' chat = JSON.parse(JSON.stringify(chat)).messages[0] if (!chat.message) return - if (chat.key && chat.key.remoteJid == 'status@broadcast') return + if (chat.key.remoteJid == 'status@broadcast') return if (chat.key.fromMe) return const from = chat.key.remoteJid const type = Object.keys(chat.message)[0] @@ -86,8 +88,9 @@ async function krypton () { if (now < expirationTime) { const timeLeft = (expirationTime - now) / 1000 - return message.reply( - `please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.` + return client.sendMessage(from, + `Mohon tunggu lebih dari ${timeLeft.toFixed(1)} detik sebelum menggunakan perintah ini *${command.name}*.`, + MessageType.text ) } } @@ -99,7 +102,7 @@ async function krypton () { command.execute(client, from, args) } catch (error) { console.error(error) - client.sendMessage(from, 'There was an error executing that command.', MessageType.text).catch(console.error) + client.sendMessage(from, 'Telah terjadi error setelah menggunakan command ini.', MessageType.text).catch(console.error) } }) } diff --git a/package.json b/package.json index baa7ae2..dd8185d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,9 @@ "@adiwajshing/baileys": "^3.4.1", "spinnies": "^0.5.1", "chalk": "^4.1.0", - "discord.js": "^12.5.1" + "discord.js": "^12.5.1", + "auto-changelog": "^2.2.1", + "moment-timezone": "^0.5.32" }, "devDependencies": { "babel-eslint": "^10.1.0", diff --git a/sessions/krypton-sessions.json b/sessions/krypton-sessions.json index 931e03e..a211abe 100644 --- a/sessions/krypton-sessions.json +++ b/sessions/krypton-sessions.json @@ -1,7 +1,7 @@ { "clientID": "GKLkqJPLYevrdohE3aqyLw==", - "serverToken": "1@BbuGj/99Mi5JiKtNvNNgJXHXByq/ZDSXQLm0CY9MDSpw7egHszko3A7QAPLjZ3cfK2iF1bWcSbafiQ==", - "clientToken": "cv9PgK6hyyCYOzuOqF5Ts5HXkOpevS2ItX4Qf7M6API=", + "serverToken": "1@QL4rgcQ89akLLPCYg86qxTB8W/FBcnyB9vUEAkPs/FiKCFKf3JaXzFTc6B9ZpWGuOcisR+YGk5GEnw==", + "clientToken": "zYkyJ4MFUHP9wz5ODkIdqVLKi0wrPAIPhe1rm9KmycQ=", "encKey": "XmgE05UerNZpLDE2RFvE8/E4jnAkN+DGhib2P1R/gQY=", "macKey": "ruFSFvGXjPPEfH00mvd6sYSJIEuAz1OPB5kK0x1c/Vo=" } \ No newline at end of file diff --git a/utils/functions.js b/utils/functions.js index 779668c..e2793c7 100644 --- a/utils/functions.js +++ b/utils/functions.js @@ -1,4 +1,5 @@ const Spin = require('spinnies') +const moment = require('moment-timezone') const spinner = { interval: 120, @@ -35,7 +36,18 @@ const success = (id, text) => { spins.succeed(id, { text: text }) } +/** + * Get Time duration + * @param {Date} timestamp + * @param {Date} now + */ +const processTime = (timestamp, now) => { + // timestamp => timestamp when message was received + return moment.duration(now - moment(timestamp)).asSeconds() +} + module.exports = { start, - success + success, + processTime }