const fs = require('fs')
const subs = JSON.parse(fs.readFileSync('./data/group/subs.json', 'utf8'))

module.exports = {
    prices: (bot, msg, logger) => {
        let string = ""
        const subPrice = "- subscription prices";
        if (msg.text && msg.text.toString().toLowerCase() === subPrice) {
            logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Got subscription Prices");
            subs.forEach(element => {
                if (element.COST != "X") {
                    let catString = element.SUB + " - £" + element.COST + "."
                    string += '\n' + catString;
                }
            });
            bot.sendMessage(msg.chat.id, string, { parse_mode: "HTML" }).then(() => {
                return bot.sendMessage(msg.chat.id, "All of these prices are for 12 Month subscription subs").then(() => {
                    return bot.sendMessage(msg.chat.id, "Keep an eye out though because we offer special deals on different subs from time to time.")
                })
            })
        }
    }
}