<commit_before>'use strict';

const Command = require('../../Command.js');
const ProfileEmbed = require('../../embeds/ProfileEmbed.js');

const inProgressEmbed = { title: 'Processing search...', color: 0xF1C40F };

/**
 * Looks up items from Nexus-stats.com
 */
class PriceCheck extends Command {
  /**
   * Constructs a callable command
   * @param {Genesis} bot  The bot object
   */
  constructor(bot) {
    super(bot, 'warframe.misc.profile', 'profile', 'profile');
    this.regex = new RegExp(`^${this.call}(?:\\s+(.+))?`, 'i');
    this.usages = [
      {
        description: 'Search for a player\'s profile',
        parameters: ['in-game name (PC only)'],
      },
    ];
  }

  /**
   * Run the command
   * @param {Message} message Message with a command to handle, reply to,
   *                          or perform an action based on parameters.
   */
  run(message) {
    const username = message.strippedContent.match(this.regex)[1].trim();
    if (typeof username === 'undefined') {
      this.sendUsageEmbed(message);
      return;
    }

    message.channel.send('', { embed: inProgressEmbed })
      .then(sentMessage => this.bot.nexusFetcher.get('/warframe/v1/bots/status')
          .then((status) => {
            let embedWithTime = {};
            if (!status['Player-Sentry'].online) {
              embedWithTime = { title: 'Profile Engine Offline. New Entries will not be processed.', color: 0xaa0000 };
            } else {
              embedWithTime = { title: `Profile Engine Online... ${status['Player-Sentry'].queue.timeRemaining} remaining...` };
            }
            return sentMessage.edit('', { embed: embedWithTime });
          }))
      .then(sentMessage => this.bot.nexusFetcher.get(`/warframe/v1/players/${username}/profile`)
          .then(profile => ({ sentMessage, profile })))
      .then(({ sentMessage, profile }) => {
        if (profile.name || profile.error === `${username} could not be found.`) {
          return sentMessage.edit('', { embed: new ProfileEmbed(this.bot, profile.name ? profile : {}) });
        }
        return null;
      })
      .catch(this.logger.error);
  }

  sendUsageEmbed(message) {
    this.bot.settings.getChannelPrefix(message.channel)
      .then((prefix) => {
        const embed = {
          type: 'rich',
          color: 0x0000ff,
          fields: [
            {<commit_msg>test profile title check<commit_after>'use strict';

const Command = require('../../Command.js');
const ProfileEmbed = require('../../embeds/ProfileEmbed.js');

const inProgressEmbed = { title: 'Processing search...', color: 0xF1C40F };

/**
 * Looks up items from Nexus-stats.com
 */
class PriceCheck extends Command {
  /**
   * Constructs a callable command
   * @param {Genesis} bot  The bot object
   */
  constructor(bot) {
    super(bot, 'warframe.misc.profile', 'profile', 'profile');
    this.regex = new RegExp(`^${this.call}(?:\\s+(.+))?`, 'i');
    this.usages = [
      {
        description: 'Search for a player\'s profile',
        parameters: ['in-game name (PC only)'],
      },
    ];
  }

  /**
   * Run the command
   * @param {Message} message Message with a command to handle, reply to,
   *                          or perform an action based on parameters.
   */
  run(message) {
    const username = message.strippedContent.match(this.regex)[1].trim();
    if (typeof username === 'undefined') {
      this.sendUsageEmbed(message);
      return;
    }

    message.channel.send('', { embed: inProgressEmbed })
      .then(sentMessage => this.bot.nexusFetcher.get('/warframe/v1/bots/status')
          .then((status) => {
            let embedWithTime = {};
            if (!status['Player-Sentry'].online) {
              embedWithTime = { title: 'Profile Engine Offline. New Entries will not be processed.', color: 0xaa0000 };
            } else {
              embedWithTime = { title: `Profile Engine Online... ${status['Player-Sentry'].queue.timeRemaining} remaining...` };
            }
            return sentMessage.edit('', { embed: embedWithTime });
          }))
      .then(sentMessage => this.bot.nexusFetcher.get(`/warframe/v1/players/${username}/profile`)
          .then(profile => ({ sentMessage, profile })))
      .then(({ sentMessage, profile }) => {
        if (profile.name || (profile.error === `${username} could not be found.`
                             && (sentMessage.embeds.length > 0 
                                 && 'Profile Engine Offline. New Entries will not be processed.' !== sentMessage.embeds[0].title))) {
          return sentMessage.edit('', { embed: new ProfileEmbed(this.bot, profile.name ? profile : {}) });
        }
        return null;
      })
      .catch(this.logger.error);
  }

  sendUsageEmbed(message) {
    this.bot.settings.getChannelPrefix(message.channel)
      .then((prefix) => {
        const embed = {
          type: 'rich',
          color: 0x0000ff,
          fields: [
            {
{'fraction_non_alphanumeric': 0.15962820771873107, 'fraction_numerical': 0.007274196807435846, 'mean_word_length': 2.2934131736526946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4870434', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1411, 'n_words': 329}