-
Notifications
You must be signed in to change notification settings - Fork 6
/
utils.js
128 lines (111 loc) · 4.59 KB
/
utils.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
module.exports = {
hello: function (message) {
return message.channel.send(`Hello <@${message.author.id}>!`);
},
clan: function (data, message, Discord) {
const embed = new Discord.RichEmbed();
embed.setTitle("Clan Informations")
.setDescription(data.description)
.setColor("#22A7F0")
.addField("Name", data.name)
.addField("Players", `${data.memberCount}/50`)
.addField("Score", data.score)
.addField("Donations", data.donations)
.addField("Required Trophies", data.requiredScore)
.setThumbnail(data.badge.image);
return message.channel.send({
embed
});
},
top: function (data, message, max, Discord) {
const embed = new Discord.RichEmbed()
.setTitle("Top Players")
.setDescription(`${max} High ranked players`);
for (let i = 0; i < data.length && i < max; i++) {
embed.addField(
`${i+1}. ${data[i].name}`,
`\:trophy: ${data[i].trophies}`
);
}
return message.channel.send({
embed
})
},
donations: function (data, message, Discord) {
const embed = new Discord.RichEmbed()
.setTitle("Top Donations Player")
.setDescription("5 Best Donations Players");
data.sort((a, b) => {
return b.donations - a.donations
});
for (let i = 0; i < data.length && i < 5; i++) {
embed.addField(
`${i+1}. ${data[i].name}`,
`\:gift: ${data[i].donations}`
);
}
return message.channel.send({
embed
})
},
player: function (data, message, Discord) {
const embed = new Discord.RichEmbed();
embed.setTitle("Player Information")
.setColor("#22A7F0")
.addField("Name", `${data.name} - Level ${data.stats.level}`)
.addField("Clan", `${data.clan.name} (${data.clan.role})`)
.addField("Max trophies", `${data.stats.maxTrophies} \:trophy:`)
.addField("Current trophies", `${data.trophies} \:trophy:`)
.addField("Total donations", data.stats.totalDonations)
.addField("Cards", `${data.stats.cardsFound}/81`)
.addField("Favorite card", data.stats.favoriteCard.name)
.addField("W/L/D", `${data.games.winsPercent*100}%/${data.games.lossesPercent*100}%/${data.games.drawsPercent*100}%`)
.addField("Challenge max win", data.stats.challengeMaxWins)
.addField("Challenge cards won", data.stats.challengeCardsWon)
.addField("Tournament cards won", data.stats.tournamentCardsWon)
.setThumbnail(data.clan.badge.image);
return message.channel.send({
embed
});
},
chest: function (data, message, img, Discord) {
const embed = new Discord.RichEmbed();
embed.setTitle("Chest informations")
.setColor("#22A7F0")
.setDescription(`Next chest incoming for ${data.name}`)
.addField("Giant", data.chestCycle.giant)
.addField("Epic", data.chestCycle.epic)
.addField("Magical", data.chestCycle.magical)
.addField("Super Magical", data.chestCycle.superMagical)
.addField("Legendary", data.chestCycle.legendary)
.setThumbnail(img);
return message.channel.send({
embed
});
},
help: function(message, Discord){
const embed = new Discord.RichEmbed();
embed.setTitle("Help")
.setColor("#FABE58")
.setDescription('Here the list of available commands')
.addField("!help", "Display this help list")
.addField("!hello", "Say hello to user")
.addField("!clan <ID>", "Display information about clan. <ID> is facultative")
.addField("!player <ID>", "Display informations about player <ID>")
.addField("!top <max>", "Display top <max> players of clan (from 0 to 25)")
.addField("!donations", "Display top 5 donors of clan")
.addField("!chest <ID>", "Display next chests incoming for player <ID>")
return message.channel.send({
embed
});
},
removeHash: function (arg) {
return arg.replace('#', '');
},
errorCommand: function (message) {
return message.channel.send(`<@${message.author.id}>: bad command!`);
},
errorOption: function (error, message) {
return message.channel.send(`<@${message.author.id}>: ${error}!`);
}
};