<commit_before>import 'jsdom-global/register'

import Discord from 'discord.js'
import Fuse from 'fuse.js'
import HearthstoneJSON from 'hearthstonejson'
import toMarkdown from 'to-markdown'

import config from './config/config'

const client = new Discord.Client()
const hsjson = new HearthstoneJSON()

client.on('ready', () => {
    console.log('Client ready')
})

client.on('message', message =>  {
  let pattern = /:{2}([^:\?]+)\??([^:]*):{2}/g
  let matches = []
  let match
  while (match = pattern.exec(message.content)) {
    matches.push(match)
  }

  if (matches.length > 0) {
    hsjson.getLatest(cards => {
      cards = cards.filter(card => { return card.collectible })
      let fuse = new Fuse(cards, { keys: ['name'] })

      matches.forEach(match => {
        let foundCards = fuse.search(match[1])
        let reply
        if (foundCards.length < 1) {
          reply = 'Sorry, I couldn\'t find anything'
        } else {
          reply = formatOutput(foundCards[0], match[2])
        }
        message.channel.sendMessage(reply)
      }, this)
    })
  }
})<commit_msg>Add typing effect while getting cards<commit_after>import 'jsdom-global/register'

import Discord from 'discord.js'
import Fuse from 'fuse.js'
import HearthstoneJSON from 'hearthstonejson'
import toMarkdown from 'to-markdown'

import config from './config/config'

const client = new Discord.Client()
const hsjson = new HearthstoneJSON()

client.on('ready', () => {
    console.log('Client ready')
})

client.on('message', message =>  {
  let pattern = /:{2}([^:\?]+)\??([^:]*):{2}/g
  let matches = []
  let match
  while (match = pattern.exec(message.content)) {
    matches.push(match)
  }

  if (matches.length > 0) {
    message.channel.startTyping()
    hsjson.getLatest(cards => {
      cards = cards.filter(card => { return card.collectible })
      let fuse = new Fuse(cards, { keys: ['name'] })

      matches.forEach(match => {
        let foundCards = fuse.search(match[1])
        let reply
        if (foundCards.length < 1) {
          reply = 'Sorry, I couldn\'t find anything'
        } else {
          reply = formatOutput(foundCards[0], match[2])
        }
        message.channel.stopTyping()
        message.channel.sendMessage(reply)
      }, this)
    })
  }
})
{'fraction_non_alphanumeric': 0.1556043956043956, 'fraction_numerical': 0.006153846153846154, 'mean_word_length': 2.924137931034483, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '700918', 'n_tokens_mistral': 754, 'n_tokens_neox': 729, 'n_words': 169}