chore: catch errors in example

This commit is contained in:
Adhiraj Singh
2022-11-25 09:04:41 +05:30
parent b20a3b9a6a
commit 2e6343f2ea

View File

@@ -1,5 +1,5 @@
import { Boom } from '@hapi/boom' import { Boom } from '@hapi/boom'
import makeWASocket, { AnyMessageContent, delay, DisconnectReason, fetchLatestBaileysVersion, isJidBroadcast, jidNormalizedUser, makeCacheableSignalKeyStore, makeInMemoryStore, MessageRetryMap, useMultiFileAuthState } from '../src' import makeWASocket, { AnyMessageContent, delay, DisconnectReason, fetchLatestBaileysVersion, isJidBroadcast, makeCacheableSignalKeyStore, makeInMemoryStore, MessageRetryMap, useMultiFileAuthState } from '../src'
import MAIN_LOGGER from '../src/Utils/logger' import MAIN_LOGGER from '../src/Utils/logger'
const logger = MAIN_LOGGER.child({ }) const logger = MAIN_LOGGER.child({ })
@@ -147,7 +147,9 @@ const startSock = async() => {
if(events['contacts.update']) { if(events['contacts.update']) {
for(const contact of events['contacts.update']) { for(const contact of events['contacts.update']) {
if(typeof contact.imgUrl !== 'undefined') { if(typeof contact.imgUrl !== 'undefined') {
const newUrl = contact.imgUrl === null ? null : await sock!.profilePictureUrl(contact.id!) const newUrl = contact.imgUrl === null
? null
: await sock!.profilePictureUrl(contact.id!).catch(() => null)
console.log( console.log(
`contact ${contact.id} has a new profile pic: ${newUrl}`, `contact ${contact.id} has a new profile pic: ${newUrl}`,
) )