This repository was archived by the owner on Jun 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathapex.js
More file actions
52 lines (46 loc) · 2.43 KB
/
apex.js
File metadata and controls
52 lines (46 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { MessageEmbed } = require("discord.js");
const { cyan } = require("../../colours.json");
const { stripIndents } = require("common-tags");
const API = require("apextab-api"), ApexTab = API.Apextab_API;
module.exports = {
config: {
name: "apex",
description: "Displays a user's apex stats!",
usage: "<user> <platform>",
category: "miscellaneous",
accessableby: "Members",
aliases: ["apec"]
},
run: async (bot, message, args) => {
if(!args[0]) return message.channel.send("Please supply a username.");
if(!args[1]) return message.channel.send("Please supply a platform to check. `pc`, `xbox` or `ps4`");
const platformCheck = { pc: API.Platform.PC, xbox: API.Platform.XBOX_ONE, ps4: API.Platform.PS4 };
const platform = platformCheck[args[1].toLowerCase()];
try {
const results = await ApexTab.searchPlayer(args[0], platform ? platform : API.Platform.PC)
for (let playerResult of results.results) {
const player = await ApexTab.getPlayerById(playerResult.aid)
const { name, skillratio, visits, avatar, legend, level, kills, headshots, matches, globalrank, utime } = player;
const embed = new MessageEmbed()
.setColor(cyan)
.setAuthor(`Origin (Apex Legends) | ${name}`, avatar)
.setThumbnail(avatar)
.setDescription(stripIndents`
**Active Legend:** ${legend || "Not Found."}
**Global Rank:** ${globalrank || "Not Ranked."}
**level:** ${level || 0}
**Skill Ratio:** ${skillratio || "0%"}
**Matches:** ${matches || 0}
**Kills:** ${kills || 0}
**Headshots:** ${headshots || 0}
**Visits:** ${visits || 0}
**PlayTime:** ${Math.ceil(utime / (1000 * 60 * 60 * 24)) || 0} days
`)
.setTimestamp()
message.channel.send(embed)
}
} catch(err) {
return message.channel.send("Can't find a player by that")
}
}
}