const fs = require('fs') const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8')) var subArray = [] subs.forEach(element => { if (element.COST != "X") { let arr = ["- " + element.SUB] subArray.push(arr) } }); subArray.push(["- Home"]) module.exports = { main: (bot, msg, logger) => { logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Asked what app to use"); bot.sendMessage(msg.chat.id, "What Subscription do you have?", { "reply_markup": { "keyboard": subArray } }) }, appSwitch: (bot, msg, logger) => { let string = "" if (subArray.some(v => msg.text.toString().includes(v))) { var checkSub = msg.text.substring(2) if (checkSub != "Home") { subs.forEach(element => { if (element.SUB === checkSub) { element.APPS.forEach(element => { let catString = element string += '\n' + catString; }) } } ); bot.sendMessage(msg.chat.id, checkSub + " can use -" + string + "\n\nAll can be downloaded from our FileLinked") } } } }