Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js'); // This is making sure that node has the package 'discord.js' installed
- const config = require("../config.json");
- const moment = require('moment');
- const Enmap = require("enmap");
- const ms = require("ms");
- const https = require("https");
- exports.run = (client, message, args) => {
- if(message.channel.name == undefined) return message.author.send(`can't use commands in dms`)
- let name = args.join(" ")
- channel = message.channel;
- name.trim()
- var spicupper = name.toUpperCase();
- var spiclower = name.toLowerCase();
- var epiclower = name.toLowerCase();
- var epicupper = name.toUpperCase();
- var clown = client.emojis.find("name", "clown");
- var dancing = client.emojis.find("name", "ClownDancing");
- var lite = client.emojis.find("name", "Lite");
- const NotAllowedWords = {
- "color": 10038562,
- "description": `${name} has not allowed words ${lite} in it's name.`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": `You have banned words in ${name} ${clown}.`,
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": `Your Account does exist${dancing}?`,
- "value": `Go on [fortnitetracker.com](https://fortnitetracker.com/profile/search?q=) and try to search your Account.\n This is using the fortnite tracker api so sometimes it won't work.`
- }]
- };
- if (epiclower.includes('epic') && name.toLowerCase() == "epic")
- {
- return message.channel.send({ embed: NotAllowedWords }) //corection is that the code will still go if it doesn't stop there
- }
- if (epicupper.includes('EPIC') && name.toUpperCase() == "EPIC")
- {
- return message.channel.send({ embed: NotAllowedWords })
- }
- if (spicupper.includes('SPIC') && name.toUpperCase() == "SPIC")
- {
- return message.channel.send({ embed: NotAllowedWords })
- }
- if (spiclower.includes('spic') && name.toLowerCase() == "spic")
- {
- return message.channel.send({ embed: NotAllowedWords })
- }
- const tolong = {
- "color": 12320855,
- "description": `${name} has to many characters${dancing}. ${clown}`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": `You have a lot of characters in ${name}.`,
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": `Your Account does exist${clown}?`,
- "value": `Go on [fortnitetracker.com](https://fortnitetracker.com/profile/search?q=) and try to search your Account.\n This is using the fortnite tracker api so sometimes it won't work.`
- }]
- };
- const lesscharacters = {
- "color": 12745742,
- "description": `${name} more characters needed. ${clown}`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": `You put only below 3 ${dancing} characters, please add more.`,
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": "Your Account does exist?",
- "value": `Go on [fortnitetracker.com](https://fortnitetracker.com/profile/search?q=) and try to search your Account.\n This is using the fortnite tracker api so sometimes it won't work.`
- }]
- };
- const notallowed = {
- "color": 15844367,
- "description": `**${name}** has characters ${dancing} that aren't allowed. ${clown}`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": 'The characters you put are not allowed in a epic Display name.',
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": "Your Account does exist?",
- "value": `Go on [fortnitetracker.com](https://fortnitetracker.com/profile/search?q=) and try to search your Account.\n This is using the fortnite tracker api so sometimes it won't work.`
- }]
- };
- var notallowedcharacters = ['/', '|', '{', '}', '[', ']', `'`, ";", ':', '"', '.', ',', '?', '>', '<', '~', '`', '-', '+', '=']
- if (name.length > 16) {
- return message.channel.send({ embed: tolong })
- }
- if (name.length < 3) {
- return message.channel.send({ embed: lesscharacters })
- }
- if(!name) return message.channel.send('Please mention a player name.')
- var PCoptions = {
- host: 'api.fortnitetracker.com',
- path: '/v1/profile/pc/' + encodeURIComponent(name),
- port: 443, // isnt this used for mail?
- method: 'GET',
- headers: { 'TRN-Api-Key': "" }
- };
- var req = https.request(PCoptions, function(res){
- var body = "";
- res.on('data', function(data){
- body += data;
- });
- res.on('end', end => {
- body = JSON.parse(body)
- var ControllerSettings = {
- host: 'api.fortnitetracker.com',
- path: '/v1/profile/psn/' + encodeURIComponent(name),
- port: 443, // isnt this used for mail?
- method: 'GET',
- headers: { 'TRN-Api-Key': "" }
- };
- var ControllerReq = https.request(ControllerSettings, function(ControllerRes){
- var ControllerBody = "";
- ControllerRes.on('data', function(data){
- ControllerBody += data;
- });
- ControllerRes.on('end', end => {
- ControllerBody = JSON.parse(ControllerBody)
- const Canceled = {
- "color": 2605136,
- "description": `The Selection was successfully aborted. ${dancing}`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": 'Selection aborted',
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- };
- const TookToLong = {
- "color": 16777215,
- "description": `The Selection was aborted after 20 seconds ${dancing}.`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": 'Selection aborted',
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- };
- const CONTROLLERNOTFOUND = {
- "color": 13182319,
- "description": `A player account with the name **${name}** on playstation ${dancing} does not exist. ${clown}`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": 'Account not found on playstation.',
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": "Your Account wasn't found?",
- "value": `Go on [fortnitetracker.com](https://fortnitetracker.com/profile/search?q=) and try to search your Account.\n This is using the fortnite tracker api so sometimes it won't work.`
- }]
- };
- const PCACCOUNTNOTFOUND = {
- "color": 10694957,
- "description": `A player account with the name **${name}** on pc ${lite} does not exist. ${clown}`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": 'Account not found on pc.',
- "url": '',
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": "Your Account wasn't found?",
- "value": `Go on [fortnitetracker.com](https://fortnitetracker.com/profile/search?q=) and try to search your Account.\n This is using the fortnite tracker api so sometimes it won't work.`
- }]
- };
- // player not found
- var loading = client.emojis.find(emoji => emoji.name === "Loading")
- var PC = client.emojis.find(emoji => emoji.name === "PC")
- var Controller = client.emojis.find(emoji => emoji.name === "Controller")
- var Touch = client.emojis.find(emoji => emoji.name === "Touch")
- var Cancel = client.emojis.find(emoji => emoji.name === "Cancel")
- const embed = {
- "color": 65280,
- "title": `Fetching Stats ${loading}`,
- };
- const Pick = {
- "color": 15844367,
- "description": "Please select the input type you want stats from.\n\n " + dancing + " Update: ``Touch is now removed because it's not supported.``\n\n" + `${PC} - Keyboard And Mouse \n${Controller} - PlayStation\n\n use ${Cancel} to cancel`,
- "thumbnail": {
- "url": ''
- },
- "author": {
- "name": 'Select the input type!',
- "url": client.user.avatarURL,
- "icon_url": ''
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": 'chingchon'
- },
- };
- var emoji = client.emojis.find(emoji => emoji.name === "for8349680231204859k9443")
- const reactionFilter = (reaction, user) => reaction.emoji.name === 'for8349680231204859k9443';
- message.channel.send(clown.name).then(msg => msg.delete(10))
- const sentmessage = message.channel.send(`${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown} ${lite} ${clown}`)
- .then(msg => msg.edit({ embed: embed })).then(msg => msg.edit({ embed: Pick }))
- .then(message2 => {
- message2.react(Cancel)
- .then(() => message2.react(PC))
- .then(() => message2.react(Controller))
- .catch(() => console.error('One of the emojis failed to react.'));
- const filter = (reaction, user) => reaction.emoji.name === PC.name && user.id === message.author.id;
- const Controllerfilter = (reaction, user) => reaction.emoji.name === Controller.name && user.id === message.author.id;
- const Cancelfilter = (reaction, user) => reaction.emoji.name === Cancel.name && user.id === message.author.id;
- message2.awaitReactions(Cancelfilter, { max: 1, time: 20000, errors: ['time'] })
- .then(collected => {
- const reaction = collected.first();
- let user = message.author;
- if (!user.bot) {
- if (reaction.emoji.name === Cancel.name) {
- return message2.edit({ embed: Canceled }),
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- req.end(),
- ControllerReq.end();
- }
- }
- })
- .catch(collected => {
- message2.edit({ embed: TookToLong })
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- });
- message2.awaitReactions(Controllerfilter, { max: 1, time: 20000, errors: ['time'] })
- .then(collected => {
- const reaction = collected.first();
- let user = message.author;
- if (!user.bot) {
- if (reaction.emoji.name === Controller.name) {
- if(ControllerBody.error){
- message2.edit({ embed: CONTROLLERNOTFOUND })
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- return;
- }
- // player found
- var epicName = ControllerBody["epicUserHandle"];
- var platform = ControllerBody["platformName"];
- var score = ControllerBody.lifeTimeStats[6]["value"];
- var matchesPlayed = ControllerBody.lifeTimeStats[7]["value"];
- var wins = ControllerBody.lifeTimeStats[8]["value"];
- //var timePlayed = body.lifeTimeStats[13]["value"]; // removed from API?
- var wr = ControllerBody.lifeTimeStats[9]["value"];
- var kills = ControllerBody.lifeTimeStats[10]["value"];
- var kd = ControllerBody.lifeTimeStats[11]["value"];
- //var killsPerMin = body.lifeTimeStats[12]["value"];
- var ControllerURL = "https://fortnitetracker.com/profile/psn/"
- + encodeURIComponent(name);
- const newEmbed = {
- "color": 5301186,
- "timestamp": new Date(),
- "thumbnail": {
- "url": message.author.avatarURL
- },
- "author": {
- "name": epicName + ', Controller Stats',
- "url": ControllerURL,
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": "Wins",
- "value": wins
- },
- {
- "name": "Matches Played",
- "value": matchesPlayed
- },
- {
- "name": "Kills",
- "value": kills
- },
- {
- "name": "Score/Match",
- "value": score
- },
- {
- "name": "Win Rate",
- "value": wr
- },
- {
- "name": "Platform",
- "value": platform
- },
- {
- "name": "Kills/Match",
- "value": kd
- },
- {
- "name": "Link",
- "value": ControllerURL
- },
- {
- "name": "API",
- "value": 'The api used to make this is the fortnite tracker api.' + `${clown}`
- }]
- };
- message2.edit({ embed: newEmbed });
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- }
- }
- })
- .catch(collected => {
- message2.edit({ embed: TookToLong })
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- });
- message2.awaitReactions(filter, { max: 1, time: 20000, errors: ['time'] })
- .then(collected => {
- const reaction = collected.first();
- let user = message.author;
- if (!user.bot) {
- if (reaction.emoji.name === PC.name) {
- if(body.error){
- message2.edit({ embed: PCACCOUNTNOTFOUND })
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- return;
- }
- // player found
- var epicName = body["epicUserHandle"];
- var platform = body["platformName"];
- var score = body.lifeTimeStats[6]["value"];
- var matchesPlayed = body.lifeTimeStats[7]["value"];
- var wins = body.lifeTimeStats[8]["value"];
- //var timePlayed = body.lifeTimeStats[13]["value"]; // removed from API?
- var wr = body.lifeTimeStats[9]["value"];
- var kills = body.lifeTimeStats[10]["value"];
- var kd = body.lifeTimeStats[11]["value"];
- //var killsPerMin = body.lifeTimeStats[12]["value"];
- var url = "https://fortnitetracker.com/profile/pc/"
- + encodeURIComponent(name);
- var msg = "";
- msg += "\nwins: " + wins;
- msg += "\ngames: " + matchesPlayed;
- msg += "\nwinrate: " + wr;
- msg += "\n\nkills: " + kills /* + " (" + killsPerMin + "/min)"*/ ;
- msg += "\nkd: " + kd;
- //msg += "\n\nplaytime: " + 0h; // disabled for a long time
- const newEmbed = {
- "color": 5301186,
- "timestamp": new Date(),
- "thumbnail": {
- "url": message.author.avatarURL
- },
- "author": {
- "name": epicName,
- "url": url,
- "icon_url": message.author.avatarURL
- },
- "footer": {
- "icon_url": client.user.avatarURL,
- "text": client.user.tag
- },
- "fields": [{
- "name": "Wins",
- "value": wins
- },
- {
- "name": "Matches Played",
- "value": matchesPlayed
- },
- {
- "name": "Kills",
- "value": kills
- },
- {
- "name": "Score/Match",
- "value": score
- },
- {
- "name": "Win Rate",
- "value": wr
- },
- {
- "name": "Platform",
- "value": platform
- },
- {
- "name": "Kills/Match",
- "value": kd
- },
- {
- "name": "Link",
- "value": url
- },
- {
- "name": "API",
- "value": 'The api used to make this is the fortnite tracker api.' + `${clown}`
- }]
- };
- message2.edit({ embed: newEmbed });
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- }
- }
- })
- .catch(collected => {
- message2.edit({ embed: TookToLong })
- message2.reactions.array().forEach(r => {
- r.remove();
- });
- });
- })
- });
- });
- ControllerReq.end();
- });
- });
- req.end();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement