diff --git a/commands/search/osu.js b/commands/search/osu.js new file mode 100644 index 00000000..e5b7e5dc --- /dev/null +++ b/commands/search/osu.js @@ -0,0 +1,65 @@ +const commando = require('discord.js-commando'); +const Discord = require('discord.js'); +const config = require('../../config.json'); +const osu = require('osu')(config.osukey); + +class OsuCommand extends commando.Command { + constructor(Client){ + super(Client, { + name: 'osu', + group: 'search', + memberName: 'osu', + description: 'Searches Osu data. (;osu dragonfire535)', + examples: [';osu dragonfire535'] + }); + } + + async run(message, args) { + if(message.channel.type !== 'dm') { + if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return; + if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return; + if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return; + } + console.log("[Command] " + message.content); + let usernametosearch = message.content.split(" ").slice(1).join(" "); + osu.get_user({ + "u": usernametosearch, + "type": 'string' + }, function(result) { + if(result[0].username === undefined) { + message.channel.sendMessage(":x: Error! User not found!"); + } else { + const embed = new Discord.RichEmbed() + .setColor(0xFF66AA) + .setAuthor('osu!', 'http://vignette3.wikia.nocookie.net/osugame/images/c/c9/Logo.png/revision/latest?cb=20151219073209') + .addField('**Username:**', + result[0].username, true) + .addField('**ID:**', + result[0].user_id, true) + .addField('**Level:**', + result[0].level, true) + .addField('**Accuracy**', + result[0].accuracy, true) + .addField('**Rank:**', + result[0].pp_rank, true) + .addField('**Play Count:**', + result[0].playcount, true) + .addField('**County:**', + result[0].country, true) + .addField('**Ranked Score:**', + result[0].ranked_score, true) + .addField('**Total Score:**', + result[0].total_score, true) + .addField('**SS:**', + result[0].count_rank_ss, true) + .addField('**S:**', + result[0].count_rank_s, true) + .addField('**A:**', + result[0].count_rank_a, true); + message.channel.sendEmbed(embed).catch(console.error); + } + }); + } +} + +module.exports = OsuCommand; \ No newline at end of file diff --git a/commands/search/urban.js b/commands/search/urban.js index 64c297f2..9435ef71 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -1,5 +1,4 @@ const commando = require('discord.js-commando'); -const Discord = require('discord.js'); const urban = require('urban'); class UrbanDictionary extends commando.Command { diff --git a/package.json b/package.json index 6488b2da..1c0abcf5 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "google-translate-api": "^2.2.2", "hepburn": "^1.0.0", "jimp": "^0.2.27", + "osu": "^1.0.1", "pirate-speak": "^1.0.1", "urban": "^0.3.1", "wikifakt": "^1.0.3",