diff --git a/example.js b/example.js index 99dc7ea..9e5eec5 100644 --- a/example.js +++ b/example.js @@ -257,6 +257,15 @@ client.on('change_state', state => { console.log('CHANGE STATE', state ); }); +// Change to false if you don't want to reject incoming calls +let rejectCalls = true; + +client.on('call', async (call) => { + console.log('Call received, rejecting. GOTO Line 261 to disable', call); + if (rejectCalls) await call.reject(); + await client.sendMessage(call.from, `[${call.fromMe ? 'Outgoing' : 'Incoming'}] Phone call from ${call.from}, type ${call.isGroup ? 'group' : ''} ${call.isVideo ? 'video' : 'audio'} call. ${rejectCalls ? 'This call was automatically rejected by the script.' : ''}`); +}); + client.on('disconnected', (reason) => { console.log('Client was logged out', reason); }); diff --git a/src/util/Constants.js b/src/util/Constants.js index d062c7a..4c22fa1 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -51,7 +51,7 @@ exports.Events = { DISCONNECTED: 'disconnected', STATE_CHANGED: 'change_state', BATTERY_CHANGED: 'change_battery', - INCOMING_CALL: 'incoming_call', + INCOMING_CALL: 'call', REMOTE_SESSION_SAVED: 'remote_session_saved' };