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 pathfortnite.js
More file actions
42 lines (38 loc) · 2.02 KB
/
fortnite.js
File metadata and controls
42 lines (38 loc) · 2.02 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
const { MessageEmbed } = require("discord.js");
const { cyan } = require("../../colours.json");
const { stripIndents } = require("common-tags");
const fortnite = require("simple-fortnite-api"), client = new fortnite("75a8798f-dd48-4ccb-9844-32f1055a5d2e");
module.exports = {
config: {
name: "fortnite",
description: "Displays a user's fortnite stats!",
usage: "<user> <platform>",
category: "miscellaneous",
accessableby: "Members",
aliases: ["ftn"]
},
run: async (bot, message, args) => {
if(!args[0]) return message.channel.send("Please supply a username.");
if(args[1] && !["lifetime", "solo", "duo", "squad"].includes(args[1])) return message.channel.send("Usage: `!fortnite <username> <gametype>`\nGameTypes: Lifetime, Solo, Duo, Squad");
let gametype = args[1] ? args[1].toLowerCase() : "lifetime";
let data = await client.find(args[0])
if(data && data.code === 404) return message.channel.send("Unable to find a user with that username.")
const { image, url, username } = data;
const { scorePerMin, winPercent, kills, score, wins, kd, matches } = data[gametype]
const embed = new MessageEmbed()
.setColor(cyan)
.setAuthor(`Epic Games (Fortnite) | ${username}`, image)
.setThumbnail(image)
.setDescription(stripIndents`**Gamemode:** ${gametype.slice(0, 1).toUpperCase() + gametype.slice(1)}
**Kills:** ${kills || 0}
**Score:** ${score || 0}
**Score Per Min:** ${scorePerMin || 0}
**Wins:** ${wins || 0}
**Win Ratio:** ${winPercent || "0%"}
**Kill/Death Ratio:** ${kd || 0}
**Matches Played:** ${matches || 0}
**Link:** [link to profile](${url})`)
.setTimestamp()
message.channel.send(embed)
}
}