-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitemamountembed.js
128 lines (121 loc) · 4.03 KB
/
itemamountembed.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
const { EmbedBuilder } = require('discord.js')
const COLORS = require('../utils/colors')
const getQuests = require('../functions/getQuests')
const getUpgrades = require('../functions/getUpgrades')
const getCrafts = require('../functions/getCrafts')
const getForgeRecipes = require('../functions/getForgeRecipes')
const itemAmountNeeded = require('../functions/itemAmountNeeded')
const date = require('../utils/date')
const ItemAmountEmbed = (item) => {
const questValues = getQuests(item).map(quest => {
let url = `/quests/${quest._id}`
switch(quest.faction) {
case 'korolev':
url = `/quests/korolev/${quest._id}`
break
case 'ica':
url = `/quests/ica/${quest._id}`
break
case 'osiris':
url = `/quests/osiris/${quest._id}`
}
return `[${quest.name}](https://tracker.thecyclefrontier.wiki${url})`
})
const upgradeValues = getUpgrades(item).map(upgrade => {
let url = `/upgrades/${upgrade._id}`
switch(upgrade.type) {
case 'Generator':
url = `/upgrades/generators/${upgrade._id}`
break
case 'Inventory':
url = `/upgrades/inventory/${upgrade._id}`
break
case 'Workbench':
url = `/upgrades/workbench/${upgrade._id}`
}
return `[${upgrade.name}](https://tracker.thecyclefrontier.wiki${url})`
})
const craftValues = getCrafts(item).map(craft => {
let url = `/crafting/${craft._id}`
switch(craft.type) {
case 'weapon':
url = `/crafting/weapons/${craft._id}`
break
case 'armor':
url = `/crafting/armor/${craft._id}`
break
case 'attachment':
url = `/crafting/attachments/${craft._id}`
break
case 'consumable':
url = `/crafting/consumables/${craft._id}`
break
case 'material':
url = `/crafting/materials/${craft._id}`
}
return `[${craft.name}](https://tracker.thecyclefrontier.wiki${url})`
})
const forgeValues = getForgeRecipes(item).map(forge => {
let url = `/forge/${forge._id}`
switch(forge.type) {
case 'perk':
url = `/forge/perks/${forge._id}`
break
case 'item':
url = `/forge/items/${forge._id}`
}
return `[${forge.name}](https://tracker.thecyclefrontier.wiki${url})`
})
const questValue = questValues.join('\n').length >= 1024 ? 'Too Many Matches!' : questValues.join('\n')
const upgradeValue = upgradeValues.join('\n').length >= 1024 ? 'Too Many Matches!' : upgradeValues.join('\n')
const craftValue = craftValues.join('\n').length >= 1024 ? 'Too Many Matches!' : craftValues.join('\n')
const forgeValue = forgeValues.join('\n').length >= 1024 ? 'Too Many Matches!' : forgeValues.join('\n')
return new EmbedBuilder()
.setColor(COLORS[item.rarity])
.setAuthor({
name: 'The Cycle: Frontier Wiki',
iconURL: 'https://tracker.thecyclefrontier.wiki/images/favicon.png'
})
.setTitle(item.name)
.setURL(`https://tracker.thecyclefrontier.wiki/item-info/${item._id}`)
.setThumbnail(`https://tracker.thecyclefrontier.wiki/images/${item._id}.png`)
.addFields(
{
name: 'Amount Needed For Quests:',
value: itemAmountNeeded(item, 'quests'),
},
{
name: 'Quests:',
value: `${questValue ? questValue : 'none'}`,
},
{
name: 'Amount Needed For Upgrades',
value: itemAmountNeeded(item, 'upgrades'),
},
{
name: 'Upgrades:',
value: `${upgradeValue ? upgradeValue : 'none'}`,
},
{
name: 'Amount Needed For Crafts:',
value: itemAmountNeeded(item, 'crafts'),
},
{
name: 'Crafts:',
value: `${craftValue ? craftValue : 'none'}`,
},
{
name: 'Amount Needed For Forge Recipes:',
value: itemAmountNeeded(item, 'forge'),
},
{
name: 'Forge Recipes:',
value: `${forgeValue ? forgeValue : 'none'}`,
}
)
.setTimestamp(new Date(date))
.setFooter({
text: 'Provided by The Cycle: Frontier Wiki'
})
}
module.exports = ItemAmountEmbed