var TvApi = require('node-lgtv-api');
var imageName = 'screen.jpg';

module.exports = {
    handle: function (ctx, message, sendMessage) {
        var lgTV = ctx.network.lgTV;
        var tvApi = new TvApi(lgTV.host, lgTV.port, lgTV.pairingKey);
        tvApi.authenticate(function (err, sessionKey) {
                if (err) {
                    console.error(err);
                } else {
                    tvApi.takeScreenShot(imageName, function (err, data) {
                        if (err) {
                            console.error(err);
                        } else {
                            ctx.log.debug(message.from.username + ' <- ' + imageName);
                            ctx.bot.sendPhoto(message.from.id, imageName, {caption: 'TV Screen'});
                        }
                    });
                }
            }
        );
    }
};

var TvApi = require('node-lgtv-api');
var imageName = 'screen.jpg';

module.exports = {
    handle: function (ctx, message, sendMessage) {
        var lgTV = ctx.config.network.lgTV;
        var tvApi = new TvApi(lgTV.host, lgTV.port, lgTV.pairingKey);
        tvApi.authenticate(function (err, sessionKey) {
                if (err) {
                    console.error(err);
                } else {
                    tvApi.takeScreenShot(imageName, function (err, data) {
                        if (err) {
                            console.error(err);
                        } else {
                            ctx.log.debug(message.from.username + ' <- ' + imageName);
                            ctx.bot.sendPhoto(message.from.id, imageName, {caption: 'TV Screen'});
                        }
                    });
                }
            }
        );
    }
};

Fix error with TV screen
Fix error with TV screen
