{"size": 1490, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "oliver-ni/nadeko-trivia-bot", "max_stars_repo_stars_event_min_datetime": "2019-01-28T01:49:38.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-29T05:02:57.000Z", "max_issues_repo_path": "index.js", "max_issues_repo_name": "oliver-ni/nadeko-trivia-bot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "oliver-ni/nadeko-trivia-bot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.8, "max_line_length": 131, "alphanum_fraction": 0.5288590604}
const Discord = require("discord.js");
const fs = require("fs");
const readline = require('readline');

let questions = JSON.parse(fs.readFileSync("qdict.json"));

function makeBot() {

    const client = new Discord.Client();

    let on = false;

    client.on("message", message => {
        if (message.author.id == 116275390695079945) {
            if (message.embeds.length == 1) {
                let embed = message.embeds[0];
                if (embed.title == "Trivia Game" && embed.fields.length == 2 && embed.fields[1].name == "Question") {
                    let question = embed.fields[1].value;
                    console.log("QUESTION – " + question);
                    if (question in questions) {
                        let answer = questions[question];
                        message.channel.send(answer);
                        console.log("ANSWERED – " + answer);
                    } else {
                        console.log("NOT FOUND");
                    }
                    console.log();
                }
            }
        }
    });

    return client;

}

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

console.log("Warning: Running Discord self-bots is aginst the Discord Terms of Service\n\n------\n\n*Discord Nadeko Trivia Bot*\n")

rl.question('What is your Discord token?\n', (answer) => {  
    const client = makeBot()
    client.login(answer);

    console.log("\nBot is running\n")
});
