/home/runner/SR12/index.js:83
lastDisconnect.error?.output?.statusCode !== DisconnectReason.loggedOut ? startAsrbot() : console.log('Koneksi Terputus...')
^
SyntaxError: Unexpected token '.'
I getting an error when running the program in repl.it, even though on my personal laptop the application runs smoothly but for some reason when I run it on repl.it it gets an error like the text above.
I've made sure there's nothing wrong, but when I run it in repl.it it gets an error, here's my code:
require('./config')
const { default: makeWASocket, useSingleFileAuthState, DisconnectReason, generateForwardMessageContent, prepareWAMessageMedia, generateWAMessageFromContent, generateMessageID, downloadContentFromMessage } = require("@adiwajshing/baileys-md")
const { state, saveState } = useSingleFileAuthState(`./${sessionName}.json`)
const pino = require('pino')
const fs = require('fs')
const chalk = require('chalk')
const fetch = require('node-fetch')
const FileType = require('file-type')
const http = require('http');
const express = require('express');
const { imageToWebp, videoToWebp, writeExifImg, writeExifVid } = require('./lib/exif')
const { smsg, isUrl, generateMessageTag } = require('./lib/myfunc')
const app = express();
app.use(express.json());
app.use('/', function(req, res) {
res.send('node-ex-api works!');
});
const server = http.createServer(app);
const port = 3000;
server.listen(port);
console.debug('Server listening on port ' + port);
global.api = (name, path = '/', query = {}, apikeyqueryname) => (name in global.APIs ? global.APIs[name] : name) + path + (query || apikeyqueryname ? '?' + new URLSearchParams(Object.entries({ ...query, ...(apikeyqueryname ? { [apikeyqueryname]: global.APIKeys[name in global.APIs ? global.APIs[name] : name] } : {}) })) : '')
async function startAsrbot() {
const asrbot = makeWASocket({
logger: pino({ level: 'silent' }),
printQRInTerminal: true,
browser: ['Asrbot Multi Device','Safari','1.0.0'],
auth: state
})
asrbot.ev.on('messages.upsert', async chatUpdate => {
//console.log(JSON.stringify(chatUpdate, undefined, 2))
try {
mek = chatUpdate.messages[0]
if (!mek.message) return
mek.message = (Object.keys(mek.message)[0] === 'ephemeralMessage') ? mek.message.ephemeralMessage.message : mek.message
if (mek.key && mek.key.remoteJid === 'status@broadcast') return
if (!asrbot.public && !mek.key.fromMe && chatUpdate.type === 'notify') return
if (mek.key.id.startsWith('BAE5') && mek.key.id.length === 16) return
m = smsg(asrbot, mek)
require("./asrbot")(asrbot, m, chatUpdate)
} catch (err) {
console.log(err)
}
})
asrbot.ev.on('group-participants.update', async (anu) => {
console.log(anu)
try {
let metadata = await asrbot.groupMetadata(anu.id)
let participants = anu.participants
for (let num of participants) {
// Get Profile Picture User
try {
ppuser = await asrbot.profilePictureUrl(num, 'image')
} catch {
ppuser = 'https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg'
}
// Get Profile Picture Group
try {
ppgroup = await asrbot.profilePictureUrl(anu.id, 'image')
} catch {
ppgroup = 'https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg'
}
if (anu.action == 'add') {
asrbot.sendMessage(anu.id, { image: { url: ppuser }, contextInfo: { mentionedJid: [num] }, caption: `Welcome To ${metadata.subject} @${num.split("@")[0]}` })
} else if (anu.action == 'remove') {
asrbot.sendMessage(anu.id, { image: { url: ppuser }, contextInfo: { mentionedJid: [num] }, caption: `@${num.split("@")[0]} Leaving To ${metadata.subject}` })
}
}
} catch (err) {
console.log(err)
}
})
// Setting
asrbot.public = true
asrbot.ev.on('connection.update', async (update) => {
const { connection, lastDisconnect } = update
if (connection === 'close') {
LINE 83 >> lastDisconnect.error?.output?.statusCode !== DisconnectReason.loggedOut ? startAsrbot() : console.log('Koneksi Terputus...')
}
console.log('Koneksi Terhubung...', update)
})
I have marked the error line (at the bottom of my script)
The version of node and npm I'm using: node : v14.17.3, npm : 6.14.13
The version of node and npm using in Replit: node : v12.22.6, npm : 6.14.15