-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
74 lines (59 loc) · 2.31 KB
/
handler.js
File metadata and controls
74 lines (59 loc) · 2.31 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
64
65
66
67
68
69
70
71
72
73
74
//==============================================================//
// JAMISON XMD //
// Handler Principal — Build Clean Ren Tech //
//==============================================================//
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const commandsDir = path.join(__dirname, "commands");
//==============================================================//
// Auto-load des commandes
//==============================================================//
const commands = new Map();
for (const file of fs.readdirSync(commandsDir)) {
if (file.endsWith(".js")) {
const cmdModule = await import(path.join(commandsDir, file));
if (!cmdModule.default || !cmdModule.name) continue;
commands.set(cmdModule.name.toLowerCase(), cmdModule.default);
console.log(`🧩 Commande chargée : ${cmdModule.name}`);
}
}
//==============================================================//
// Fonction globale : contextInfo Auto Ren Tech
//==============================================================//
global.sendRen = async (sock, jid, message) => {
return sock.sendMessage(jid, {
...message,
contextInfo: {
externalAdReply: {
title: "Ren Tech - Channel Officiel",
body: "view channel",
mediaType: 1,
sourceUrl: "https://whatsapp.com/channel/0029VbBjwT52f3ELVPsK6V2K"
}
}
});
};
//==============================================================//
// Handler Principal
//==============================================================//
export async function handler(sock, m) {
try {
const text =
m.message?.conversation ||
m.message?.extendedTextMessage?.text ||
"";
if (!text) return;
const prefix = ".";
if (!text.startsWith(prefix)) return;
const args = text.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!commands.has(commandName)) return;
const execute = commands.get(commandName);
console.log(`➡️ Commande exécutée : ${commandName}`);
await execute(sock, m, args);
} catch (err) {
console.error("❌ Erreur Handler :", err);
}
}