├── .gitignore
├── LICENSE
├── README.md
├── index.js
├── key.json
├── lib
└── messages.js
├── package.json
└── sansekai.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | package-lock.json
3 | session.json
4 | yusril
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 M Yusril
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Wa-OpenAI
2 |
3 | ***WhatsApp OpenAI ChatGPT Create with NodeJS Using Library [Baileys](https://github.com/WhiskeySockets/Baileys)***
4 |
5 | ## BACA DULU
6 | Terdapat 2 fitur yaitu ```ChatGPT(text)``` dan ```DALL-E(Text To Image).```
Untuk commandnya menggunakan ```/ai``` dan ```/img```
7 |
8 | ## Get OpenAI ChatGPT ApiKey
9 | Silakan buat apikeynya terlebih dahulu [Disini](https://beta.openai.com/account/api-keys)
10 |
11 | ## Add OpenAI ChatGPT Key ##
12 | Masukkan ApiKey OpenAI pada file [key.json](https://github.com/Sansekai/Wa-OpenAI/blob/main/key.json#L2)
13 |
14 | ## Requirements
15 | - [Node.js](https://nodejs.org/en/download/) v20 atau di atasnya
16 | - [Git](https://git-scm.com/downloads)
17 |
18 | ## Install
19 |
20 | 1. **Clone the repository**
21 | ```sh
22 | git clone https://github.com/Sansekai/Wa-OpenAI.git
23 | ```
24 | 2. **Install the dependencies**
25 | ```sh
26 | npm install
27 | ```
28 |
29 | 3. **Run**
30 | ```bash
31 | $ node index.js
32 | ```
33 |
34 | ## Donate
35 |
36 |
37 | ## License
38 | [MIT License](https://github.com/Sansekai/Wa-OpenAI/blob/main/LICENSE)
39 |
40 | Copyright (c) 2022 M Yusril
41 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
2 | const {
3 | makeWASocket,
4 | fetchLatestBaileysVersion,
5 | DisconnectReason,
6 | useMultiFileAuthState,
7 | makeCacheableSignalKeyStore,
8 | makeInMemoryStore,
9 | Browsers,
10 | } = require("@whiskeysockets/baileys");
11 | const fs = require("fs");
12 | const Pino = require("pino");
13 | const chalk = require("chalk");
14 | const moment = require("moment-timezone");
15 | moment.tz.setDefault("Asia/Jakarta").locale("id");
16 | const { Messages } = require("./lib/messages.js");
17 | const donet = "https://saweria.co/sansekai";
18 |
19 | // Baileys
20 | const Logger = {
21 | level: "error",
22 | };
23 | const logger = Pino({
24 | ...Logger,
25 | });
26 | const Store = (log = logger) => {
27 | const store = makeInMemoryStore({ logger: log });
28 | return store;
29 | };
30 | const store = Store(logger);
31 | store?.readFromFile("./session.json");
32 |
33 | setInterval(() => {
34 | store?.writeToFile("./session.json");
35 | }, 10_000);
36 |
37 | const color = (text, color) => {
38 | return !color ? chalk.green(text) : chalk.keyword(color)(text);
39 | };
40 |
41 | async function connectToWhatsApp(use_pairing_code = false) {
42 | const { state, saveCreds } = await useMultiFileAuthState("yusril");
43 |
44 | const { version } = await fetchLatestBaileysVersion();
45 | const sock = makeWASocket({
46 | auth: {
47 | creds: state.creds,
48 | keys: makeCacheableSignalKeyStore(state.keys, logger),
49 | },
50 | version: version,
51 | logger: logger,
52 | printQRInTerminal: true,
53 | markOnlineOnConnect: true,
54 | generateHighQualityLinkPreview: true,
55 | browser: Browsers.macOS('Chrome'),
56 | getMessage
57 | });
58 |
59 | store?.bind(sock.ev);
60 |
61 | sock.ev.process(async (ev) => {
62 | if (ev["creds.update"]) {
63 | await saveCreds();
64 | }
65 | if (ev["connection.update"]) {
66 | console.log("Connection update", ev["connection.update"]);
67 | const update = ev["connection.update"];
68 | const { connection, lastDisconnect } = update;
69 | if (connection === "close") {
70 | const shouldReconnect =
71 | lastDisconnect.error?.output?.statusCode !== DisconnectReason.loggedOut;
72 | console.log(
73 | "connection closed due to ",
74 | lastDisconnect.error,
75 | ", reconnecting ",
76 | shouldReconnect
77 | );
78 | // reconnect if not logged out
79 | if (shouldReconnect) {
80 | connectToWhatsApp();
81 | }
82 | } else if (connection === "open") {
83 | const botNumber = sock.user.id
84 | console.log("opened connection");
85 | console.log(color("Bot success conneted to server", "green"));
86 | console.log(color("Donate for creator https://saweria.co/sansekai", "yellow"));
87 | console.log(color("Type /menu to see menu"));
88 | sock.sendMessage(botNumber, { text: `Bot started!\n\njangan lupa support ya bang :)\n${donet}` });
89 | }
90 | }
91 | // sock.ev.on("messages.upsert", async (message) => {
92 | // console.log(message);
93 | // })
94 |
95 | const upsert = ev["messages.upsert"];
96 | if (upsert) {
97 | if (upsert.type !== "notify") {
98 | return;
99 | }
100 | const message = Messages(upsert, sock);
101 | if (!message || message.sender === "status@broadcast") {
102 | return;
103 | }
104 | // msgHandler(upsert, sock, store, message);
105 | require("./sansekai.js")(upsert, sock, store, message);
106 | }
107 |
108 |
109 | // const message = Messages(upsert, sock);
110 | // console.log(message);
111 | // }
112 | });
113 | /**
114 | *
115 | * @param {import("@whiskeysockets/baileys").WAMessageKey} key
116 | * @returns {import("@whiskeysockets/baileys").WAMessageContent | undefined}
117 | */
118 | async function getMessage(key) {
119 | if (store) {
120 | const msg = await store.loadMessage(key.remoteJid, key.id);
121 | return msg?.message || undefined;
122 | }
123 | // only if store is present
124 | return proto.Message.fromObject({});
125 | }
126 | return sock;
127 | }
128 | connectToWhatsApp()
129 | // Baileys
130 |
131 | let file = require.resolve(__filename);
132 | fs.watchFile(file, () => {
133 | fs.unwatchFile(file);
134 | console.log(chalk.redBright(`Update ${__filename}`));
135 | delete require.cache[file];
136 | require(file);
137 | });
--------------------------------------------------------------------------------
/key.json:
--------------------------------------------------------------------------------
1 | {
2 | "keyopenai": "ISI_APIKEY_OPENAI_DISINI",
3 | "donasi": "jangan lupa support ya bang :) https://saweria.co/sansekai"
4 | }
5 |
--------------------------------------------------------------------------------
/lib/messages.js:
--------------------------------------------------------------------------------
1 | const {
2 | getContentType,
3 | jidNormalizedUser,
4 | downloadContentFromMessage
5 | } = require("@whiskeysockets/baileys");
6 | const fs = require("fs");
7 |
8 | const mimeMap = {
9 | imageMessage: "image",
10 | videoMessage: "video",
11 | stickerMessage: "sticker",
12 | documentMessage: "document",
13 | audioMessage: "audio",
14 | pttMessage: "audio"
15 | };
16 |
17 | /**
18 | * Download the media from the message.
19 | * @param {import("@whiskeysockets/baileys").proto.IMessage} message - The message object.
20 | * @param {string} type - The media type.
21 | * @returns {Promise} - The media buffer.
22 | */
23 | const downloadMedia = async (message, pathFile) => {
24 | const type = Object.keys(message)[0];
25 | try {
26 | const stream = await downloadContentFromMessage(message[type], mimeMap[type]);
27 | const buffer = [];
28 | for await (const chunk of stream) {
29 | buffer.push(chunk);
30 | }
31 | if (pathFile) {
32 | await fs.promises.writeFile(pathFile, Buffer.concat(buffer));
33 | return pathFile;
34 | } else {
35 | return Buffer.concat(buffer);
36 | }
37 | } catch (e) {
38 | console.log(message)
39 | throw e;
40 | }
41 | };
42 |
43 | /**
44 | * Process an incoming message and return an extended WAMessage object.
45 | *
46 | * @param {import("@whiskeysockets/baileys").BaileysEventMap["messages.upsert"]} upsert - The upsert event object.
47 | * @param {import("@whiskeysockets/baileys").WASocket} sock - The WASocket object.
48 | * @returns {import("@whiskeysockets/baileys").WAMessage & ExtendedWAMessage | null} - The extended WAMessage object or null if invalid.
49 | */
50 | function Messages(upsert, sock) {
51 | const m = Serialize(upsert, sock);
52 | if (m.quoted) {
53 | m.quoted.react = (emoji) =>
54 | sock.sendMessage(m.chat, {
55 | react: {
56 | text: String(emoji),
57 | key: m.quoted.key,
58 | },
59 | });
60 |
61 | m.quoted.delete = () => sock.sendMessage(m.chat, { delete: m.quoted.key });
62 | m.quoted.download = (pathFile) => downloadMedia(m.quoted.message, pathFile);
63 | }
64 |
65 | m.react = (emoji) =>
66 | sock.sendMessage(m.chat, {
67 | react: {
68 | text: String(emoji),
69 | key: m.key,
70 | },
71 | });
72 |
73 | m.reply = (text) =>
74 | sock.sendMessage(
75 | m.chat,
76 | {
77 | text: text,
78 | },
79 | { quoted: m, ephemeralExpiration: m.contextInfo.expiration }
80 | );
81 |
82 | /**
83 | * Represents a function that updates a message with new text.
84 | * @typedef {function(string | null): Promise} UpdateCallback
85 | * @param {string | null} n_text - The new text to set (or null to keep the original text).
86 | * @returns {Promise} - A Promise that resolves when the update is complete.
87 | */
88 |
89 | /**
90 | *
91 | * @param {string} text - The initial text to send.
92 | * @param {undefined | (function(UpdateCallback): void)} cb - A callback function that receives an update function.
93 | * @returns {function(UpdateCallback): void} - The update function.
94 | */
95 | const replyUpdate = async (text, cb) => {
96 | const response = await sock.sendMessage(
97 | m.chat,
98 | { text: String(text) },
99 | { quoted: m }
100 | );
101 | if (typeof cb === "function") {
102 | await cb(async (n_text) =>
103 | sock.sendMessage(m.chat, { text: n_text || "", edit: response.key })
104 | ).catch(() => {});
105 | }
106 | async function update(n_text) {
107 | await sock.sendMessage(m.chat, { text: String(n_text), edit: response.key });
108 | }
109 | return update;
110 | };
111 | m.replyUpdate = replyUpdate;
112 |
113 | m.delete = () => sock.sendMessage(m.chat, { delete: m.key });
114 | m.download = (pathFile) => downloadMedia(m.message, pathFile);
115 |
116 | sock.user.id = jidNormalizedUser(sock.user.id);
117 | return m;
118 | }
119 |
120 | function Serialize(upsert, sock) {
121 | const { messages } = upsert;
122 | const m = messages[0];
123 | if (m.key) {
124 | const { id, remoteJid } = m.key;
125 | m.id = id;
126 | m.isGroup = remoteJid.endsWith("@g.us");
127 | m.chat = jidNormalizedUser(remoteJid);
128 | m.sender = jidNormalizedUser(
129 | m.isGroup ? m.key.participant : m.key.fromMe ? sock.user.id : remoteJid
130 | );
131 | }
132 |
133 | if (!m.message) {
134 | return m;
135 | }
136 |
137 | m.mtype = getContentType(m.message);
138 |
139 | if (m.mtype === "ephemeralMessage") {
140 | m.message = m.message[m.mtype].message;
141 | m.mtype = getContentType(m.message);
142 | }
143 |
144 | if (
145 | m.mtype === "viewOnceMessageV2" ||
146 | m.mtype === "documentWithCaptionMessage"
147 | ) {
148 | m.message = m.message[m.mtype].message;
149 | }
150 |
151 | m.mtype = getContentType(m.message);
152 |
153 | try {
154 | m.contextInfo = m.message[m.mtype]?.contextInfo || {};
155 | m.mentionedJid = m.contextInfo?.mentionedJid || [];
156 | m.mentionMe = m.mentionedJid[0] === sock.user.id;
157 | const quoted = m.contextInfo.quotedMessage || null;
158 | if (quoted) {
159 | if (quoted.ephemeralMessage) {
160 | const type = Object.keys(quoted.ephemeralMessage.message)[0];
161 | const message =
162 | type === "documentMessage"
163 | ? quoted.ephemeralMessage.message.documentMessage
164 | : quoted.ephemeralMessage.message[type]?.message;
165 |
166 | m.quoted = {
167 | participant: jidNormalizedUser(m.contextInfo.participant),
168 | message: message || quoted.ephemeralMessage.message,
169 | };
170 | } else {
171 | const type = Object.keys(quoted)[0];
172 | const message = quoted[type]?.message;
173 |
174 | m.quoted = {
175 | participant: jidNormalizedUser(m.contextInfo.participant),
176 | message: message || quoted,
177 | };
178 | }
179 | m.quoted.sender = m.quoted.participant;
180 | m.quoted.mtype = Object.keys(m.quoted.message)[0];
181 | m.quoted.mentionedJid =
182 | m.quoted.message[m.quoted.mtype].contextInfo?.mentionedJid || [];
183 |
184 | m.quoted.text =
185 | m.quoted.message?.conversation ||
186 | m.quoted.message[m.quoted.mtype]?.text ||
187 | m.quoted.message[m.quoted.mtype]?.description ||
188 | m.quoted.message[m.quoted.mtype]?.caption ||
189 | m.quoted.message[m.quoted.mtype]?.hydratedTemplate?.hydratedContentText ||
190 | "";
191 | m.quoted.key = {
192 | id: m.contextInfo.stanzaId,
193 | fromMe: m.quoted.sender === jidNormalizedUser(sock.user.id),
194 | remoteJid: m.chat,
195 | ...(m.isGroup ? { participant: m.contextInfo.participant } : {}),
196 | };
197 | m.quoted.mtype =
198 | m.quoted.message[m.quoted.mtype]?.mimetype || getContentType(m.quoted.message);
199 | } else {
200 | m.quoted = null;
201 | }
202 |
203 | m.text =
204 | m.message[m.mtype]?.caption ||
205 | m.message[m.mtype]?.text ||
206 | m.message[m.mtype]?.conversation ||
207 | m.message?.conversation ||
208 | "";
209 |
210 | /**
211 | * Broken logic.
212 | * mtype = the media mimetype if is a media, else @type {keyof import("@whiskeysockets/baileys").proto.Message}
213 | * type = @type {keyof import("@whiskeysockets/baileys").proto.Message}
214 | */
215 | m.type = m.mtype;
216 | m.mtype = m.message[m.mtype]?.mimetype || getContentType(m.message);
217 | } catch (e) {
218 | console.log(e);
219 | }
220 | return m;
221 | }
222 |
223 | module.exports = {
224 | Messages,
225 | Serialize
226 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Wa-OpenAI",
3 | "version": "2.1.0",
4 | "description": "WhatsApp Bot OpenAI ChatGPT Using Lib Baileys Multi Device",
5 | "main": "index.js",
6 | "type": "commonjs",
7 | "scripts": {
8 | "start": "node index.js"
9 | },
10 | "keywords": [
11 | "termux",
12 | "whatsapp-openai",
13 | "whatsapp-openai",
14 | "whatsapp-bot",
15 | "whatsapp-baileys",
16 | "baileys-md",
17 | "bot-wa",
18 | "bot-md",
19 | "whatsapp-multi-device"
20 | ],
21 | "base": "https://github.com/DikaArdnt/Hisoka-Morou",
22 | "author": "Yusril",
23 | "license": "MIT",
24 | "dependencies": {
25 | "@hapi/boom": "^10.0.0",
26 | "@whiskeysockets/baileys": "^6.7.16",
27 | "awesome-phonenumber": "^2.64.0",
28 | "axios": "^1.3.4",
29 | "chalk": "^4.1.2",
30 | "crypto": "^1.0.1",
31 | "figlet": "^1.5.2",
32 | "fs": "0.0.1-security",
33 | "lodash": "^4.17.21",
34 | "moment-timezone": "^0.5.46",
35 | "openai": "^4.20.1",
36 | "pino": "^7.0.5",
37 | "qrcode-terminal": "^0.12.0",
38 | "util": "^0.12.4"
39 | },
40 | "directories": {
41 | "lib": "lib",
42 | "src": "src"
43 | },
44 | "repository": {
45 | "type": "git",
46 | "url": "git+https://github.com/Sansekai/Wa-OpenAI.git"
47 | },
48 | "bugs": {
49 | "url": "https://github.com/Sansekai/Wa-OpenAI/issues"
50 | },
51 | "homepage": "https://github.com/Sansekai/Wa-OpenAI#readme"
52 | }
53 |
--------------------------------------------------------------------------------
/sansekai.js:
--------------------------------------------------------------------------------
1 | const { BufferJSON, WA_DEFAULT_EPHEMERAL, generateWAMessageFromContent, proto, generateWAMessageContent, generateWAMessage, prepareWAMessageMedia, areJidsSameUser, getContentType } = require("@whiskeysockets/baileys");
2 | const fs = require("fs");
3 | const util = require("util");
4 | const chalk = require("chalk");
5 | const OpenAI = require("openai");
6 | let setting = require("./key.json");
7 | const openai = new OpenAI({ apiKey: setting.keyopenai });
8 |
9 | module.exports = sansekai = async (upsert, sock, store, message) => {
10 | try {
11 | let budy = (typeof message.text == 'string' ? message.text : '')
12 | // var prefix = /^[\\/!#.]/gi.test(body) ? body.match(/^[\\/!#.]/gi) : "/"
13 | var prefix = /^[\\/!#.]/gi.test(budy) ? budy.match(/^[\\/!#.]/gi) : "/";
14 | const isCmd = budy.startsWith(prefix);
15 | const command = budy.replace(prefix, "").trim().split(/ +/).shift().toLowerCase();
16 | const args = budy.trim().split(/ +/).slice(1);
17 | const pushname = message.pushName || "No Name";
18 | const botNumber = sock.user.id;
19 | const itsMe = message.sender == botNumber ? true : false;
20 | let text = (q = args.join(" "));
21 | const arg = budy.trim().substring(budy.indexOf(" ") + 1);
22 | const arg1 = arg.trim().substring(arg.indexOf(" ") + 1);
23 | const from = message.chat;
24 |
25 | const color = (text, color) => {
26 | return !color ? chalk.green(text) : chalk.keyword(color)(text);
27 | };
28 |
29 | // Group
30 | const groupMetadata = message.isGroup ? await sock.groupMetadata(message.chat).catch((e) => {}) : "";
31 | const groupName = message.isGroup ? groupMetadata.subject : "";
32 |
33 | // Push Message To Console
34 | let argsLog = budy.length > 30 ? `${q.substring(0, 30)}...` : budy;
35 |
36 | if (isCmd && !message.isGroup) {
37 | console.log(chalk.black(chalk.bgWhite("[ LOGS ]")), color(argsLog, "turquoise"), chalk.magenta("From"), chalk.green(pushname), chalk.yellow(`[ ${message.sender.replace("@s.whatsapp.net", "")} ]`));
38 | } else if (isCmd && message.isGroup) {
39 | console.log(
40 | chalk.black(chalk.bgWhite("[ LOGS ]")),
41 | color(argsLog, "turquoise"),
42 | chalk.magenta("From"),
43 | chalk.green(pushname),
44 | chalk.yellow(`[ ${message.sender.replace("@s.whatsapp.net", "")} ]`),
45 | chalk.blueBright("IN"),
46 | chalk.green(groupName)
47 | );
48 | }
49 |
50 | if (isCmd) {
51 | switch (command) {
52 | case "help": case "menu": case "start": case "info":
53 | message.reply(`*Whatsapp Bot OpenAI*
54 |
55 | *(ChatGPT)*
56 | Cmd: ${prefix}ai
57 | Tanyakan apa saja kepada AI.
58 |
59 | *(DALL-E)*
60 | Cmd: ${prefix}img
61 | Membuat gambar dari teks
62 |
63 | *(Source Code Bot)*
64 | Cmd: ${prefix}sc
65 | Menampilkan source code bot yang dipakai`)
66 | break;
67 | case "ai": case "openai": case "chatgpt": case "ask":
68 | try {
69 | // tidak perlu diisi apikeynya disini, karena sudah diisi di file key.json
70 | if (setting.keyopenai === "ISI_APIKEY_OPENAI_DISINI") return message.reply("Apikey belum diisi\n\nSilahkan isi terlebih dahulu apikeynya di file key.json\n\nApikeynya bisa dibuat di website: https://beta.openai.com/account/api-keys");
71 | if (!text) return message.reply(`Chat dengan AI.\n\nContoh:\n${prefix}${command} Apa itu resesi`);
72 | const chatCompletion = await openai.chat.completions.create({
73 | messages: [{ role: 'user', content: q }],
74 | model: 'gpt-3.5-turbo'
75 | });
76 |
77 | await message.reply(chatCompletion.choices[0].message.content);
78 | } catch (error) {
79 | if (error.response) {
80 | console.log(error.response.status);
81 | console.log(error.response.data);
82 | } else {
83 | console.log(error);
84 | message.reply("Maaf, sepertinya ada yang error :"+ error.message);
85 | }
86 | }
87 | break;
88 | case "img": case "ai-img": case "image": case "images": case "dall-e": case "dalle":
89 | try {
90 | // tidak perlu diisi apikeynya disini, karena sudah diisi di file key.json
91 | if (setting.keyopenai === "ISI_APIKEY_OPENAI_DISINI") return message.reply("Apikey belum diisi\n\nSilahkan isi terlebih dahulu apikeynya di file key.json\n\nApikeynya bisa dibuat di website: https://beta.openai.com/account/api-keys");
92 | if (!text) return message.reply(`Membuat gambar dari AI.\n\nContoh:\n${prefix}${command} Wooden house on snow mountain`);
93 | const image = await openai.images.generate({
94 | model: "dall-e-3",
95 | prompt: q,
96 | n: 1,
97 | size: '1024x1024'
98 | });
99 | //console.log(response.data.data[0].url) // see the response
100 | sock.sendMessage(from,
101 | { image: { url: image.data[0].url }, caption: "DALE-E" },
102 | { quoted: message, ephemeralExpiration: message.contextInfo.expiration });
103 | } catch (error) {
104 | if (error.response) {
105 | console.log(error.response.status);
106 | console.log(error.response.data);
107 | console.log(`${error.response.status}\n\n${error.response.data}`);
108 | } else {
109 | console.log(error);
110 | message.reply("Maaf, sepertinya ada yang error :"+ error.message);
111 | }
112 | }
113 | break;
114 | case "sc": case "script": case "scbot":
115 | message.reply("Bot ini menggunakan script dari https://github.com/Sansekai/Wa-OpenAI");
116 | break
117 | default: {
118 | if (isCmd && budy.toLowerCase() != undefined) {
119 | if (message.chat.endsWith("broadcast")) return;
120 | if (message.isBaileys) return;
121 | if (!budy.toLowerCase()) return;
122 | if (argsLog || (isCmd && !message.isGroup)) {
123 | // sock.sendReadReceipt(message.chat, message.sender, [message.key.id])
124 | console.log(chalk.black(chalk.bgRed("[ ERROR ]")), color("command", "turquoise"), color(`${prefix}${command}`, "turquoise"), color("tidak tersedia", "turquoise"));
125 | } else if (argsLog || (isCmd && message.isGroup)) {
126 | // sock.sendReadReceipt(message.chat, message.sender, [message.key.id])
127 | console.log(chalk.black(chalk.bgRed("[ ERROR ]")), color("command", "turquoise"), color(`${prefix}${command}`, "turquoise"), color("tidak tersedia", "turquoise"));
128 | }
129 | }
130 | }
131 | }
132 | }
133 | } catch (err) {
134 | message.reply(util.format(err));
135 | }
136 | };
137 |
138 | let file = require.resolve(__filename);
139 | fs.watchFile(file, () => {
140 | fs.unwatchFile(file);
141 | console.log(chalk.redBright(`Update ${__filename}`));
142 | delete require.cache[file];
143 | require(file);
144 | });
145 |
--------------------------------------------------------------------------------