{"size": 680, "ext": "js", "max_stars_repo_path": "commands/avatar.js", "max_stars_repo_name": "nakinami/ccc", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "commands/avatar.js", "max_issues_repo_name": "nakinami/ccc", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commands/avatar.js", "max_forks_repo_name": "nakinami/ccc", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.3333333333, "max_line_length": 124, "alphanum_fraction": 0.6044117647}
/*
set avatar to base 64 images
*/
const request = require('superagent')

module.exports = (self) => {
  self.registerCommand('avatar', function (msg, args) {

 request.get(args[0])
  .end((err, res) => {
   	// If there is an error getting the emoji
   if (err) { this.log.err(err, 'avatar'); return this.send(msg, 'error it broke') }
   	// If no error
   if (res.body && res.statusCode === 200) {
   const buf = res.body
   const type = buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF ? 'data:image/jpeg;base64,' : 'data:image/png;base64,'

   avatar = `${type}${res.body.toString('base64')}`
   self.editSelf({avatar: avatar})
  this.send(msg, "avatar set")
	}})
  })
}
