Skip to content

Commit 60b8008

Browse files
message await
using `awaitMessages()` with the fortnite api.
1 parent 6595eae commit 60b8008

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

ep27/fnite.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const Discord = require("discord.js");
2+
const Client = require("fortnite");
3+
const fkey = require("../fortnite.json")
4+
const fortnite = new Client(fkey.token)
5+
module.exports.run = async (bot, message, args) => {
6+
//this is where the actual code for the command goes
7+
await message.delete();
8+
if (message.author.id !== '178657593030475776') return;
9+
10+
const filter = m => m.author.id === message.author.id;
11+
message.reply("Please chose a username... Will expire in 10 seconds...").then(q => q.delete(15000))
12+
message.channel.awaitMessages(filter, {
13+
max: 1,
14+
time: 10000
15+
}).then(collected => {
16+
collected.delete(15000);
17+
if (collected.first().content === 'cancel') {
18+
return message.reply("Canceled.");
19+
}
20+
21+
let username = collected.first().content;
22+
23+
fortnite.user(username, 'pc').then(data => {
24+
//console.log(data.stats.lifetime)
25+
let embed = new Discord.RichEmbed()
26+
.setTitle(username)
27+
.setColor("BLURPLE")
28+
.setDescription("Lifetime Stats")
29+
.setThumbnail(bot.user.displayAvatarURL)
30+
.addField("Top 3s", data.stats.lifetime[1]["Top 3s"], true)
31+
.addField("Top 5s", data.stats.lifetime[0]["Top 5s"], true)
32+
.addField("Wins", data.stats.lifetime[8]["Wins"], true)
33+
.addField("Win/Lose", data.stats.lifetime[9]["Win%"], true)
34+
.addField("Kills", data.stats.lifetime[10]["Kills"], true)
35+
.addField("K/D", data.stats.lifetime[11]["K/d"], true);
36+
return message.channel.send(embed);
37+
}).catch(err => {
38+
message.reply("Could not find user... Double check spelling").then(r => r.delete(5000));
39+
});
40+
}).catch(err => {
41+
message.reply("Cancelled...").then(r => r.delete(5000));
42+
console.log("Time exceeded. Message await cancelled.");
43+
});
44+
}
45+
//name this whatever the command name is.
46+
module.exports.help = {
47+
name: "fnite",
48+
alias: "ft"
49+
}

0 commit comments

Comments
 (0)