-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforgeembed.js
84 lines (79 loc) · 2.82 KB
/
forgeembed.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
const { EmbedBuilder } = require("discord.js")
const COLORS = require("../utils/colors")
const date = require("../utils/date")
const ForgeEmbed = (forge) => {
let url = `/forge/${forge._id}`
switch(forge.type) {
case 'perk':
url = `/forge/perks/${forge._id}`
break
case 'item':
url = `/forge/items/${forge._id}`
}
const costs = []
if (forge.cost1) costs.push(`${forge.amount1.replace(/\B(?=(\d{3})+(?!\d))/g,",")} ${forge.cost1}`)
if (forge.cost2) costs.push(`${forge.amount2.replace(/\B(?=(\d{3})+(?!\d))/g,",")} ${forge.cost2}`)
if (forge.cost3) costs.push(`${forge.amount3.replace(/\B(?=(\d{3})+(?!\d))/g,",")} ${forge.cost3}`)
if (forge.cost4) costs.push(`${forge.amount4.replace(/\B(?=(\d{3})+(?!\d))/g,",")} ${forge.cost4}`)
if (forge.cost5) costs.push(`${forge.amount5.replace(/\B(?=(\d{3})+(?!\d))/g,",")} ${forge.cost5}`)
const costsValues = costs.join('\n')
const type = forge.type.split(' ').map(value => value[0].toUpperCase() + value.substring(1)).join(' ')
const Compatability = []
if (forge.backpack) Compatability.push(`Backpack: ${forge.backpack}`)
if (forge.shield) Compatability.push(`Shield: ${forge.shield}`)
if (forge.helmet) Compatability.push(`Helmet: ${forge.helmet}`)
const compatabilityValue = Compatability.join('\n')
const rarity = forge.rarity ? forge.rarity.split(' ').map(value => value[0].toUpperCase() + value.substring(1)).join(' ') : null
return new EmbedBuilder()
.setColor(forge.rarity ? COLORS[forge.rarity] : COLORS['legendary'])
.setAuthor({
name: 'The Cycle: Frontier Wiki',
iconURL: 'https://tracker.thecyclefrontier.wiki/images/favicon.png'
})
.setTitle(forge.name)
.setURL(`https://tracker.thecyclefrontier.wiki${url}`)
.setThumbnail(`https://tracker.thecyclefrontier.wiki${forge.img}`)
.addFields([
{
name: 'Type:',
value: type,
inline: true,
},
{
name: 'Rarity:',
value: `${rarity ? rarity : 'none'}`,
inline: true,
},
{
name: 'Item Chance:',
value: `${forge.itemChance ? forge.itemChance : 'none'}`,
inline: true,
},
{
name: 'Armor Value:',
value: `${forge.armorValue ? forge.armorValue : 'none'}`,
inline: true
},
{
name: 'Compatability:',
value: `${compatabilityValue ? compatabilityValue : 'none'}`,
},
{
name: 'Minimum Stat:',
value: `${forge.minimumstat ? forge.minimumstat : 'none'}`,
},
{
name: 'Maximum Stat:',
value: `${forge.maximumstat ? forge.maximumstat : 'none'}`,
},
{
name: 'Compatible Items:',
value: costsValues
}
])
.setTimestamp(new Date(date))
.setFooter({
text: 'Provided by The Cycle: Frontier Wiki'
})
}
module.exports = ForgeEmbed