How to use the node-emoji.hasEmoji function in node-emoji

To help you get started, we’ve selected a few node-emoji examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github peterthehan / holo / src / commands / users.js View on Github external
database.ref(`guilds/${message.guild.id}/messages`).once('value', (snapshot) => {
      const db = snapshot.val();
      if (!db) {
        error(message, '', `My records are empty!`);
        return;
      }

      // determine emoji
      filter = emoji.hasEmoji(filter)
        ? emoji.unemojify(filter)
        : filter.match(/:\d+>/)[0];
      filter = filter.substring(1, filter.length - 1);

      usersInfo(message, db, filter);
    }, (errorObject) => {
      console.log('The read failed: ' + errorObject.code);
github peterthehan / holo / src / util / processEmojis.js View on Github external
calculateRate: (message, c) => {
    // todo: handle case for when bot leaves guild and rejoins
    const count = Object.assign({}, c);

    for (let i of Object.keys(count)) {
      // convert ms to days
      const time = (Date.now() - (emoji.hasEmoji(i)
        ? message.guild.members.get(message.client.user.id).joinedTimestamp
        : message.guild.emojis.get(i).createdTimestamp)) / 86400000;

      count[i] = +(count[i] / time).toFixed(2);
    }

    return count;
  },
  sortData: (count, isDescending) => {
github LeaPhant / flowabot / commands / emote.js View on Github external
emotes.forEach(emoteName => {
            let emote;

            if(emoteName.startsWith("<:") && emoteName.split(":").length > 1)
                emoteName = emoteName.split(":")[1];

            if(emoji.hasEmoji(emoteName))
                emote = emoji.find(emoteName).emoji;
            else if(msg.channel.type == 'text')
                emote = helper.emote(emoteName, msg.guild, client);
            else
                emote = helper.emote(emoteName, null, client);

            if(emote)
                output += emote.toString();
            else
                output += " " + emoteName;
        });
github peterthehan / holo / src / commands / users.js View on Github external
let filter = args.find(i => {
    let serverEmojis = i.match(/:\d+>/);
    if (serverEmojis) {
      serverEmojis = serverEmojis[0].substring(1, serverEmojis[0].length - 1);
    }

    return emoji.hasEmoji(i) || message.guild.emojis.has(serverEmojis);
  });
  if (filter) {
github garden-io / garden / src / log.ts View on Github external
function format(opts: LogOpts) {
  const { emoji, section, symbol, msg, entryStyle } = opts
  let out = ""
  let pre = ""
  if (entryStyle) {
    pre = {
      info: chalk.bold.green("Info "),
      warn: chalk.bold.yellow("Warning "),
      error: chalk.bold.red("Error "),
      none: "",
    }[entryStyle] || ""
  }
  out += pre
  out += symbol ? `${logSymbols[symbol]} ` : ""
  out += emoji && nodeEmoji.hasEmoji(emoji) ? `${nodeEmoji.get(emoji)} ` : ""
  out += section ? `${sectionStyle(section)} → ` : ""
  out += msgStyle(msg)
  return out
}
github peterthehan / holo / src / util / parseEmojis.js View on Github external
      .filter(i => emoji.hasEmoji(i))
      .map(i => i.substring(1, i.length - 1));
github garden-io / garden / garden-service / src / logger / util.ts View on Github external
export function printEmoji(emoji: EmojiName, log: LogEntry) {
  if (log.root.useEmoji && nodeEmoji.hasEmoji(emoji)) {
    return `${nodeEmoji.get(emoji)} `
  }
  return ""
}
github peterthehan / holo / src / util / collectEmojis.js View on Github external
return users[index].map(j => {
            return formatEmojis(message, i, j.id, emoji.hasEmoji(i), true);
          });
        })
github frinyvonnick / gitmoji-changelog / packages / gitmoji-changelog-core / src / parser.js View on Github external
function parseSubject(subject) {
  if (!subject) return {}

  const unemojified = nodeEmoji.unemojify(subject)

  const matches = unemojified.match(/:(\w*):(.*)/)

  if (matches) {
    const [, emojiCode, message] = matches

    if (nodeEmoji.hasEmoji(emojiCode)) {
      return {
        emojiCode,
        emoji: nodeEmoji.get(emojiCode),
        message: nodeEmoji.emojify(message.trim()),
      }
    }
  }

  return {
    message: subject,
  }
}