Comparing version 1.1.7 to 1.1.8
{ | ||
"name": "retrocord", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "The best in life", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,4 +0,1 @@ | ||
const Discord = require('discord.js'); | ||
const superagent = require('superagent'); | ||
module.exports = (vorpal) => { | ||
@@ -11,30 +8,17 @@ const { chalk, discord, timestamp } = vorpal; | ||
if (vorpal.current.channel) { | ||
const start = Date.now(); | ||
const url = `https://discordapp.com/api/guilds/${vorpal.current.guild}/messages/search?content=${args.query.join(' ')}${args.options.guild ? '' : `&channel_id=${vorpal.current.channel}`}`; | ||
superagent.get(url).set('Authorization', discord.token).end((err, res) => { | ||
if (res.body.total_results === 0 || err || res.body.code) { | ||
vorpal.log(chalk.bold('Error:', res.body.code ? 'Still indexing...' : null || 'No results found!')); | ||
return cb(); | ||
} else { | ||
let results = res.body.messages.map(x => { | ||
const m = x.find(z => z.hit); | ||
return new Discord.Message(discord.channels.get(m.channel_id), m, discord); | ||
}); | ||
const occurances = {}; | ||
for (const m of results) { | ||
if (!occurances[m.author.id]) occurances[m.author.id] = 0; | ||
occurances[m.author.id]++; | ||
} | ||
let highestUser = discord.users.get(Object.keys(occurances)[Object.values(occurances).indexOf(Object.values(occurances).sort().reverse()[0])]); | ||
highestUser = `${highestUser.username}#${highestUser.discriminator}`; | ||
results = results.map(r => chalk.bold(`${chalk.yellow(timestamp(new Date(r.createdAt), true))} ${r.author.username}#${r.author.discriminator} `) + r.cleanContent) | ||
.slice(0, args.options.show || 10).reverse(); | ||
const end = Date.now(); | ||
vorpal.log(chalk.bold(`Found ${res.body.total_results} results in ${end - start}ms (showing ${results.length})`)); | ||
vorpal.log(`Highest User: ${highestUser}`); | ||
vorpal.log(chalk.bold('-- BEGIN SEARCH --')); | ||
vorpal.log(results.join('\n')); | ||
vorpal.log(chalk.bold('--- END SEARCH ---')); | ||
return cb(); | ||
} | ||
discord.channels.get(vorpal.current.channel).search({ | ||
content: args.query.join(' '), | ||
}) | ||
.then(r => r.messages) | ||
.then(r => r.map(msgs => msgs.find(m => m.hit))) | ||
.then(messages => { | ||
vorpal.log(chalk.bold('-- BEGIN SEARCH --')); | ||
const results = messages | ||
.map(r => chalk.bold(`${chalk.yellow(timestamp(new Date(r.createdAt), true))} ${r.author.tag} `) + r.cleanContent) | ||
.slice(0, args.options.show || 10) | ||
.reverse() | ||
.join('\n'); | ||
console.log(results); | ||
vorpal.log(chalk.bold('--- END SEARCH ---')); | ||
return cb(); | ||
}); | ||
@@ -41,0 +25,0 @@ } else { |
@@ -188,1 +188,3 @@ #!/usr/bin/env node | ||
} | ||
process.on('unhandledRejection', () => {}); // eslint-disable-line no-empty-function |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7
299437
548