mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +00:00
feat: battery percentage changed event (#126)
New "change_battery" event is triggered when the battery percentage changes. Has current battery percentage and charging state as object param. Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
@@ -237,6 +237,12 @@ client.on('group_update', (notification) => {
|
||||
console.log('update', notification);
|
||||
});
|
||||
|
||||
client.on('change_battery', (batteryInfo) => {
|
||||
// Battery percentage for attached device has changed
|
||||
const { battery, plugged } = batteryInfo;
|
||||
console.log(`Battery: ${battery}% - Charging? ${plugged}`);
|
||||
});
|
||||
|
||||
client.on('disconnected', (reason) => {
|
||||
console.log('Client was logged out', reason);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user