levix-bot 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +0,0 @@
1
- // file: /commands/shutdown.js (Now with shell command execution)
2
- const { delay } = require("@whiskeysockets/baileys");
3
- const { exec } = require("child_process"); // 1. Import the 'exec' function
4
- const logger = require("../utils/logger.cjs");
5
- const { tr } = require("../utils/i18n.cjs");
6
-
7
- module.exports = {
8
- name: "shutdown",
9
- description: {
10
- en: "Stops the bot process permanently (via PM2).",
11
- ar: "يوقف عملية البوت نهائيًا (عبر PM2).",
12
- },
13
- usage: {
14
- en: "shutdown",
15
- ar: "shutdown",
16
- },
17
- chat: "all",
18
-
19
- async execute(sock, msg) {
20
- const commandToExecute = "pm2 stop wa-bot"; // The exact command to run on the server
21
-
22
- logger.warn(`Received !shutdown command. Executing: ${commandToExecute}`);
23
-
24
- // 2. Send a final message to the user before shutting down
25
- await sock.sendMessage(msg.key.remoteJid, {
26
- text: tr(
27
- "🔌 Shutdown received. Stopping the bot now... goodbye! 👋",
28
- "🔌 تم استلام أمر الإيقاف النهائي. سيتم إيقاف البوت الآن... وداعًا! 👋",
29
- ),
30
- });
31
-
32
- // A small delay to ensure the WhatsApp message is sent out
33
- await delay(2000);
34
-
35
- // 3. Execute the shell command
36
- exec(commandToExecute, (error, stdout, stderr) => {
37
- if (error) {
38
- // This log is crucial if something goes wrong
39
- logger.error(
40
- {
41
- err: error.message,
42
- stderr: stderr,
43
- },
44
- `Failed to execute shutdown command: ${commandToExecute}`,
45
- );
46
-
47
- // We can't reliably send a message here because the process might be stopping.
48
- return;
49
- }
50
-
51
- // This log will appear just before the process is stopped by PM2
52
- logger.info(`PM2 stop command executed successfully. STDOUT: ${stdout}`);
53
- });
54
- },
55
- };