diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7f4826d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}/BotsApp.ts", + "outFiles": ["${workspaceFolder}/dist/**/*.js"] + } + ] +} \ No newline at end of file diff --git a/BotsApp.ts b/BotsApp.ts index e13f43e..bd92e84 100644 --- a/BotsApp.ts +++ b/BotsApp.ts @@ -162,42 +162,44 @@ setInterval(() => { if (upsert.type !== 'notify') { return; } - let chat: proto.IWebMessageInfo = upsert.messages[0]; - let BotsApp: BotsApp = await resolve(chat, sock); - // console.log(BotsApp); - if (BotsApp.isCmd) { - let isBlacklist: boolean = await Blacklist.getBlacklistUser(BotsApp.sender, BotsApp.chatId); - const cleared: boolean = await clearance(BotsApp, client, isBlacklist); - if (!cleared) { - return; - } - const reactionMessage = { - react: { - text: "🪄", - key: chat.key, + for(const msg of upsert.messages){ + let chat: proto.IWebMessageInfo = msg; + let BotsApp: BotsApp = await resolve(chat, sock); + // console.log(BotsApp); + if (BotsApp.isCmd) { + let isBlacklist: boolean = await Blacklist.getBlacklistUser(BotsApp.sender, BotsApp.chatId); + const cleared: boolean = await clearance(BotsApp, client, isBlacklist); + if (!cleared) { + return; } - } - await sock.sendMessage(chat.key.remoteJid, reactionMessage); - console.log(chalk.redBright.bold(`[INFO] ${BotsApp.commandName} command executed.`)); - const command = commandHandler.get(BotsApp.commandName); - var args = BotsApp.body.trim().split(/\s+/).slice(1); - if (!command) { - client.sendMessage(BotsApp.chatId, "```Woops, invalid command! Use``` *.help* ```to display the command list.```", MessageType.text); - return; - } else if (command && BotsApp.commandName == "help") { - try { - command.handle(client, chat, BotsApp, args, commandHandler); + const reactionMessage = { + react: { + text: "🪄", + key: chat.key, + } + } + await sock.sendMessage(chat.key.remoteJid, reactionMessage); + console.log(chalk.redBright.bold(`[INFO] ${BotsApp.commandName} command executed.`)); + const command = commandHandler.get(BotsApp.commandName); + var args = BotsApp.body.trim().split(/\s+/).slice(1); + if (!command) { + client.sendMessage(BotsApp.chatId, "```Woops, invalid command! Use``` *.help* ```to display the command list.```", MessageType.text); return; + } else if (command && BotsApp.commandName == "help") { + try { + command.handle(client, chat, BotsApp, args, commandHandler); + return; + } catch (err) { + console.log(chalk.red("[ERROR] ", err)); + return; + } + } + try { + await command.handle(client, chat, BotsApp, args).catch(err => console.log("[ERROR] " + err)); } catch (err) { console.log(chalk.red("[ERROR] ", err)); - return; } } - try { - await command.handle(client, chat, BotsApp, args).catch(err => console.log("[ERROR] " + err)); - } catch (err) { - console.log(chalk.red("[ERROR] ", err)); - } } } } diff --git a/tsconfig.json b/tsconfig.json index b93031e..c6611c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,8 @@ "outDir": "./dist", /* Redirect output structure to the directory. */ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ "allowSyntheticDefaultImports": true, - "allowJs": true + "allowJs": true, + "sourceMap": true }, "exclude": ["**/*.test.ts", "./dist/**/*"],