{"size": 1719, "ext": "js", "max_stars_repo_path": "src/handlers/wordCatcher.js", "max_stars_repo_name": "MarsRon/phobos", "max_stars_repo_stars_event_min_datetime": "2021-04-11T05:04:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-17T16:26:23.000Z", "max_issues_repo_path": "src/handlers/wordCatcher.js", "max_issues_repo_name": "MarsRon/phobos", "max_issues_repo_issues_event_min_datetime": "2021-08-13T12:40:16.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-13T12:40:16.000Z", "max_forks_repo_path": "src/handlers/wordCatcher.js", "max_forks_repo_name": "MarsRon/phobos", "max_forks_repo_forks_event_min_datetime": "2021-04-03T10:27:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-23T05:24:17.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 2, "avg_line_length": 27.2857142857, "max_line_length": 74, "alphanum_fraction": 0.5584642234}
const client = require('../client')
const emoji = require('../emoji.json')

const normalWords = [
  // Note: Please put "not?\s+<keyword>" first before "<keyword>"
  [
    /idk|i\s+don'?t\s+know/,
    message => `ask \`${message.prefix}8ball\` it will know`
  ],
  [/not?\s+sad/, 'Yes, be happy! \\:)'],
  [/sad/, "Don't be sad, I'm here for you \\:)"],
  [/not?\s+nice/, 'Not nice \\:('],
  [/nice/, 'Nice'],
  [/shut|stfu/, 'shut'],
  [/fu(?:c|k|ck)\s+(:yo)?u|(?:yo)?u\s+suck?/, 'No u'],
  [/n(?:o+?|u+?)b/, emoji.unoreverse],
  [/<@!?738252807525892139>/, 'why ping me'],
  [/phobos/, 'who called me']
]

const catchers = [
  function normal (text, message) {
    const match = normalWords.find(kv => kv[0].test(text))
    if (match) {
      return typeof match[1] === 'function' ? match[1](message) : match[1]
    }
  },
  function imDad (text, message) {
    const match = text.match(/\bi\s*['`a]?\s*m(?:\s+|\b)/)
    if (match) {
      return `Hi **${
        match[0].length
          ? message.content.slice(match.index + match[0].length)
          : 'blank'
      }**, I'm dad!`
    }
  }
]

// If you wanna be blacklisted just add your user ID here
const blacklist = ['548770927039610921']

module.exports = async message => {
  const { author, content, guild } = message
  if (blacklist.includes(author.id)) return
  const text = content.toLowerCase()
  let response
  catchers.some(func => (response = func(text, message)) !== undefined)
  if (response) {
    message.reply(response)
    client.log.info(
      `Word catcher: ${JSON.stringify({
        user: author.tag,
        id: author.id,
        guild: guild?.name,
        guildId: guild?.id,
        content,
        response
      })}`
    )
  }
}
