Files
tasJS/index.js
2018-07-09 22:22:51 -04:00

56 lines
1.7 KiB
JavaScript

import prompts from 'prompts';
import Creator from './Creator';
import Trivia from './trivia';
import Summary from './Summary';
import Weekly from './Weekly';
import Cashout from './Cashout';
import TopPlayers from './TopPlayers';
import Avatar from './Avatar';
import * as config from './config';
import { LOG_TYPES } from './constants';
const choices = [
{ title: 'Play Trivia', select: () => new Trivia().run() },
{ title: 'Create Account', select: () => new Creator().run() },
{ title: 'Update Weekly Lives', select: () => new Weekly().run() },
{ title: 'Change Avatars', select: () => new Avatar().run() },
{ title: 'Show Player Summaries', select: () => new Summary().run() },
{ title: 'Show Top Players', select: () => new TopPlayers().run() },
{ title: 'Cashout', select: () => new Cashout().run() },
];
const getChoice = async () => {
console.log(LOG_TYPES.WARNING('#######################################'));
console.log(LOG_TYPES.WARNING('# REMEMBER TO VPN WHILE RUNNING #'));
console.log(LOG_TYPES.WARNING('#######################################'));
console.log();
console.log('Welcome to Trivia Automation Suite 1.0');
console.log('What would you like to do?\n');
choices.forEach(({ title }, index) => console.log(`${index + 1}) ${title}`));
console.log();
const response = await prompts({
type: 'number',
name: 'choice',
message: 'Choice:',
});
const { choice } = response;
if (choice < 1 || choice > choices.length) {
console.log('Invalid selection!');
return null;
}
return choice;
};
const main = async () => {
const choice = await getChoice();
if (!choice) return;
choices[choice - 1].select();
};
main();