forked from juma-tec/MALIK-MD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathping.js
41 lines (35 loc) · 1.34 KB
/
ping.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
Copyright (C) 2022.
Licensed under the GPL-3.0 License;
You may not use this file except in compliance with the License.
It is supplied in the hope that it may be useful.
* @project_name : MALIK-MD
* @author : arkhan998 <https://github.com/arkhan998>
* @description : malik,A Multi-functional whatsapp bot.
* @version 0.0.7
**/
//---------------------------------------------------------------------------
const Secktor = require('../lib');
Secktor.cmd({
pattern: "ping",
desc: "To check ping",
category: "general",
filename: __filename,
},
async (Void, citel) => {
var initial = new Date().getTime();
const { key } = await Void.sendMessage(citel.chat, { text: '```Pinging from server```' });
var final = new Date().getTime();
// Calculate the ping value in milliseconds
const pingValue = final - initial;
// Create a loading bar
const loadingBarLength = 20;
const loadedBlocks = loadingBarLength;
const loadingBar = '█'.repeat(loadedBlocks);
// Send the loading bar first
await Void.sendMessage(citel.chat, { text: `*Pong*\nLoading: [${loadingBar}] 100%`, edit: key });
// Wait for a brief moment (you can customize this delay)
await Secktor.sleep(1000);
// Send the final ping message
return await Void.sendMessage(citel.chat, { text: `*Ping: ${pingValue} ms*` });
});