From 68d32ab1fa9c79e848038ca1c451e7d8f368531b Mon Sep 17 00:00:00 2001 From: 8cy <50817549+8cy@users.noreply.github.com> Date: Wed, 29 Apr 2020 04:36:14 -0700 Subject: Cerasus, v9.0.0 basically just add an insane amount of things - all new animal commands - waifu cmds - change/ move clientid, invite, uwufy, support, howify, say, pfp - add ip, security key, vote, datefacts, githubzen, fmk, fml, offsptring, facts, rate, opinion, onion, quantum coin, rolldie, romannumerals, russianrullete, smashorpass, spoiler, sub - minecraft cmds - SERVER check cmds - lewd cmds - roleplay commands - fun commands and games - utils --- src/commands/utility/fortnitestats.ts | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/commands/utility/fortnitestats.ts (limited to 'src/commands/utility/fortnitestats.ts') diff --git a/src/commands/utility/fortnitestats.ts b/src/commands/utility/fortnitestats.ts new file mode 100644 index 0000000..88a50a0 --- /dev/null +++ b/src/commands/utility/fortnitestats.ts @@ -0,0 +1,101 @@ +import { Command, CommandoMessage } from 'discord.js-commando'; +import { MessageEmbed } from 'discord.js'; +import emoji from 'emoji-random' +import axios from 'axios' +import config from '../../config.json' +const platforms = ['pc', 'xbl', 'psn'] + +module.exports = class FortniteStatsUtility extends Command { + constructor(client) { + super(client, { + name: 'fortnitestats', + aliases: [ + 'fortnite-stats', + 'fortnitestatistics', + 'fortnite-statistics', + 'fnstats', + 'fn-stats', + 'fnstatistics', + 'fn-statistics', + 'fns', + 'fn-s' + ], + group: 'utility', + memberName: 'fortnitestats', + description: 'Grabs a specified player\' Fortnite statistics.', + details: 'Available platforms are `pc` (PC), `xbp` (Xbox Live) and `psn` (Playstation Network).', + examples: [ + 'uwu!fortnitestats Frozen', + 'uwu!fns Sin' + ], + userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], + throttling: { + usages: 5, + duration: 30 + }, + args: [ + { + key: 'pPlatform', + prompt: 'What platform would you like to search on.', + type: 'string', + parse: platform => platform.toLowerCase(), + oneOf: platforms + }, + { + key: 'pUsername', + prompt: 'What user would you like to look up?', + type: 'string' + } + ] + }); + } + async run(msg: CommandoMessage, { pPlatform, pUsername }) { + try { + const stats = ( + await axios + .get(`https://api.fortnitetracker.com/v1/profile/${pPlatform}/${pUsername}`, { + headers: { 'TRN-Api-Key': config.fortniteTrackerNetworkToken } + }) + .catch(err => { + console.error(err) + return msg.reply('Woops, There was an error with the (https://api.fortnitetracker.com) API. ' + emoji.random()) + }) + ).data + + if (stats.error === 'Player Not Found') { + return msg.reply('Specified player was not found on that platform. ' + emoji.random()) + } + + console.debug(`Result for ${pUsername} on ${pPlatform}:`, stats) + let emb = new MessageEmbed() + .setTitle(stats.epicUserHandle) + .setURL(`https://fortnitetracker.com/profile/${pPlatform}/${encodeURIComponent(pUsername)}`) + .setColor(0xFFCC4D) + .setFooter('Information providied by The Tracker Network.',) + + if (stats.lifeTimeStats[8] && stats.lifeTimeStats[9]) { + emb.addField("🏆 Wins", `${stats.lifeTimeStats[8].value} wins (${stats.lifeTimeStats[9].value})`) + } + + if (stats.lifeTimeStats[10] && stats.lifeTimeStats[11]) { + emb.addField( + "💀 Kills", + `${stats.lifeTimeStats[10].value} kills. ${stats.lifeTimeStats[11].value} K/D ratio.` + ); + } + + if (stats.lifeTimeStats[7]) { + emb.addField("🎮 Matches Played", stats.lifeTimeStats[7].value.toString()); + } + + if (stats.lifeTimeStats[6]) { + emb.addField("🔢 Score", stats.lifeTimeStats[6].value.toString()); + } + + return msg.replyEmbed(emb); + } finally { + msg.channel.stopTyping() + } + } +}; \ No newline at end of file -- cgit v1.2.3