{"size": 1556, "ext": "js", "max_stars_repo_path": "commands/gameinfo.js", "max_stars_repo_name": "DevHitori/Fiverr-Job-005", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "commands/gameinfo.js", "max_issues_repo_name": "DevHitori/Fiverr-Job-005", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commands/gameinfo.js", "max_forks_repo_name": "DevHitori/Fiverr-Job-005", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.8275862069, "max_line_length": 111, "alphanum_fraction": 0.6073264781}
const Discord = require("discord.js");
const fs = require("fs");
date = new Date();

module.exports.run = async (client, message, args, prefix) => {

  if (!args[0]) {
    let e = new Discord.RichEmbed()
    .setTitle('Proper Usuage: !gameinfo [CODE]')
    .setColor("#36393F");
    message.channel.send(e);
    return;
  }

  if (args[0].startsWith('#')) {
    args[0] = args[0].slice(1)
  }
  let active =true;
  let res = await db.collection('Active Games').findOne({code: args[0]})
  if (!res) {
    res = await db.collection('Old Games').findOne({code: args[0]})
    active = false
  }
  if (!res) {
    let e = new Discord.RichEmbed()
    .setTitle('A game with that code could not be found.')
    .setColor("#36393F");
    message.channel.send(e);
    return;
  }else{
    let e = new Discord.RichEmbed()
    .addField('Code:', `3${res.code}`)
    .addField('Creator:', client.users.get(res.creador).username,true)
    .addField('State:', res.estado,true)
    .setThumbnail(client.user.avatarURL)
    .setColor("#36393F");

    if (res.estado != 'starting'){
      e.addField('Red Team:', res.teamRed.map(d => `\n${client.users.get(d).username}`),true)
      e.addField('Blue Team:', res.teamBlue.map(d => `\n${client.users.get(d).username}`),true)
    }
    if (res.estado == 'finished'){e.addField(`Mafia:`,res.mafia.map(d => `\n${client.users.get(d).username}`))}
    message.channel.send(e);
    return;
  }




}

module.exports.info = {
  name: "gameinfo",
  aliases: [],
  description: "Usage: !gameinfo [Game Code]",
  usuage: "gameinfo",
}
