-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrun.js
More file actions
63 lines (58 loc) · 2.97 KB
/
run.js
File metadata and controls
63 lines (58 loc) · 2.97 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const ascii = `⠀⠀⠀╔═════════════════════════════════╗
║ ⚡ KINGVON MD ⚡ ║
║ ⌜ WhatsApp Bot Interface ⌟ ║
╠═════════════════════════════════╣
║ ⭔ Creator : KINGVON ║
║ ⭔ Type : Multi-featured ║
║ ⭔ Status : Ready & Running💯🚀║
║ ⭔ Mode : ${bot.public ? '✱ Public ༣' : '✲ Self ༣'} ║
║ ⭔ Users : ${Object.keys(db.data.users).length} ║
║ ⭔ Prefix : Single ║
║ ⭔ Uptime : ${run} ║
╚═════════════════════════════════╝
🔧 Use ${prefix}menu to start⠀⠀`
const chalk = require("chalk")
const Connecting = async ({
update,
conn,
Boom,
DisconnectReason,
sleep,
color,
clientstart,
}) => {
const { connection, lastDisconnect } = update;
if (connection === 'close') {
const reason = new Boom(lastDisconnect?.error)?.output.statusCode;
console.log(color(lastDisconnect.error, 'deeppink'));
if (lastDisconnect.error == 'Error: Stream Errored (unknown)') {
process.exit();
} else if (reason === DisconnectReason.badSession) {
console.log(chalk.red.bold(`bad session file, please delete session and scan again`));
process.exit();
} else if (reason === DisconnectReason.connectionClosed) {
console.log(chalk.red.bold('connection closed, reconnecting...'));
process.exit();
} else if (reason === DisconnectReason.connectionLost) {
console.log(chalk.red.bold('connection lost, trying to reconnect'));
process.exit();
} else if (reason === DisconnectReason.connectionReplaced) {
console.log(chalk.red.bold('connection replaced, another new session opened, please close current session first'));
conn.logout();
} else if (reason === DisconnectReason.loggedOut) {
console.log(chalk.red.bold(`device logged out, please scan again and run.`));
conn.logout();
} else if (reason === DisconnectReason.restartRequired) {
console.log(chalk.yellow.bold('restart required,restarting...'));
await clientstart();
} else if (reason === DisconnectReason.timedOut) {
console.log(chalk.yellow.bold('connection timedOut, reconnecting...'));
clientstart();
}
} else if (connection === "connecting") {
console.log(chalk.blue.bold('connecting . . .'));
} else if (connection === "open") {
console.log(`${ascii}`)
console.log(chalk.blue.bold('bot successfully connected'));
}}
module.exports = { Connecting };