Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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) => {
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;
});
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) {
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
}
.filter(i => emoji.hasEmoji(i))
.map(i => i.substring(1, i.length - 1));
export function printEmoji(emoji: EmojiName, log: LogEntry) {
if (log.root.useEmoji && nodeEmoji.hasEmoji(emoji)) {
return `${nodeEmoji.get(emoji)} `
}
return ""
}
return users[index].map(j => {
return formatEmojis(message, i, j.id, emoji.hasEmoji(i), true);
});
})
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,
}
}