Skip to content

Commit de2a103

Browse files
committed
Add links to site in commands
1 parent 9506be9 commit de2a103

File tree

8 files changed

+69
-31
lines changed

8 files changed

+69
-31
lines changed

src/commands/artifacts/artifact.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AutocompleteInteraction, CommandInteraction, Message, MessageEmbed } fr
22

33
import Command from "../../utils/Command"
44
import client from "../../main"
5-
import { Colors, createTable, findFuzzyBestCandidates, getLinkToGuide, sendMessage, simplePaginator } from "../../utils/Utils"
5+
import { Colors, createTable, findFuzzyBestCandidates, getLinkToGuide, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
66
import { Artifact, CommandSource, SendMessage } from "../../utils/Types"
77
import config from "../../data/config.json"
88

@@ -103,6 +103,7 @@ Note: this command supports fuzzy search.`,
103103

104104
const embed = new MessageEmbed()
105105
.setTitle("Artifact Sets")
106+
.setURL(`${client.data.baseURL}artifacts`)
106107
.setDescription(pages[relativePage])
107108
.setFooter(`Page ${currentPage} / ${maxPages} - See '${config.prefix}help artifact' for more info about what you can do`)
108109
.setColor(Colors.GREEN)
@@ -115,6 +116,7 @@ Note: this command supports fuzzy search.`,
115116
const embed = new MessageEmbed()
116117
.setColor(Colors.AQUA)
117118
.setThumbnail(`${data.baseURL}${set.artis.find(x => x.icon)?.icon ?? "img/unknown.png"}`)
119+
.setURL(`${data.baseURL}artifacts/${urlify(set.name, false)}`)
118120
.setFooter(`Page ${currentPage} / ${maxPages}`)
119121

120122
if (relativePage == 0) {
@@ -140,6 +142,7 @@ Note: this command supports fuzzy search.`,
140142
const total = mainStats.map(m => m.weight).reduce((a, b) => a+b, 0)
141143

142144
embed.setTitle(`${arti.name}`)
145+
.setURL(`${data.baseURL}artifacts/${urlify(set.name, false)}#artis`)
143146
.setDescription(arti.desc)
144147
.addField("Possible main stats", `\`\`\`
145148
${createTable(

src/commands/characters/character.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import config from "../../data/config.json"
33
import client from "../../main"
44
import Command from "../../utils/Command"
55
import { BotEmoji, Character, CharacterFull, CommandSource, SendMessage, Skill, TalentTable, TalentValue } from "../../utils/Types"
6-
import { addArg, Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLinkToGuide, PAD_END, PAD_START, paginator, sendMessage, simplePaginator } from "../../utils/Utils"
6+
import { addArg, Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLinkToGuide, PAD_END, PAD_START, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
77

88

99
const elementTypes = client.data.getCharacters()
@@ -195,6 +195,7 @@ Note: this command supports fuzzy search.`,
195195

196196
const embed = new MessageEmbed()
197197
.setTitle("Character list")
198+
.setURL(`${client.data.baseURL}characters`)
198199
.setDescription(pages[relativePage])
199200
.setFooter(`Page ${currentPage} / ${maxPages} - See '${config.prefix}help char' for more info about what you can do`)
200201
.setColor(Colors.GREEN)
@@ -223,6 +224,7 @@ Note: this command supports fuzzy search.`,
223224

224225
if (relativePage == 0) {
225226
embed.setTitle(`${char.name}: Description`)
227+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}`)
226228
.setDescription(char.desc)
227229
.addField("Basics", this.getBasicInfo(char))
228230

@@ -323,6 +325,7 @@ Note: this command supports fuzzy search.`,
323325
metadata += `**Element**: ${char.meta.element}\n`
324326

325327
embed.setTitle(`${char.name}: Information`)
328+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#meta`)
326329
.setDescription(metadata.trim())
327330

328331
const va: string[] = []
@@ -391,7 +394,8 @@ Note: this command supports fuzzy search.`,
391394
embed.addField(`Ascension ${asc.level} costs`, data.getCosts(cost), true)
392395
}
393396

394-
embed.setTitle(`${char.name}: Ascensions + stats`)
397+
embed.setTitle(`${char.name}: Stats + ascensions`)
398+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#stats`)
395399
.setDescription("Character stats:\n```\n" + createTable(
396400
["Lvl", "Asc", ...columns.map(c => data.statName(c))],
397401
rows,
@@ -412,6 +416,7 @@ Note: this command supports fuzzy search.`,
412416
}
413417

414418
embed.setTitle(`${char.name}: Talent upgrade costs`)
419+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#talents`)
415420
.setColor(Colors[skills.ult?.type ?? "None"])
416421
return embed
417422
}
@@ -420,12 +425,14 @@ Note: this command supports fuzzy search.`,
420425
}
421426

422427
getMediaPage(char: Character, relativePage: number, currentPage: number, maxPages: number): MessageEmbed | undefined {
428+
const { data } = client
423429
const embed = new MessageEmbed()
424430
.setColor(Colors[char.meta.element] ?? "")
425431
.setFooter(`Page ${currentPage} / ${maxPages}`)
426432
.setTitle(`${char.name}`)
433+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#videos`)
427434
if (char.icon)
428-
embed.setThumbnail(`${client.data.baseURL}${char.icon}`)
435+
embed.setThumbnail(`${data.baseURL}${char.icon}`)
429436

430437
const videos = char.media.videos ? (`**Promotional Videos**
431438
${ Object
@@ -447,19 +454,21 @@ ${ Object
447454
}
448455

449456
getCharTalentPage(char: Character, relativePage: number, currentPage: number, maxPages: number, talentMode: TalentMode): MessageEmbed | undefined {
457+
const { data } = client
450458
const embed = new MessageEmbed()
451459
.setColor(Colors[char.meta.element] ?? "")
452460
.setFooter(`Page ${currentPage} / ${maxPages}`)
453461

454462
if (char.icon)
455-
embed.setThumbnail(`${client.data.baseURL}${char.icon}`)
463+
embed.setThumbnail(`${data.baseURL}${char.icon}`)
456464

457465
function isValueTable(talent: TalentTable | TalentValue): talent is TalentTable {
458466
return (talent as TalentTable).values != undefined
459467
}
460468

461469
function showTalent(skill: Skill): void {
462470
embed.setTitle(`${char.name}: ${skill.name}`)
471+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#${urlify(skill.name, false)}`)
463472
.setDescription(skill.desc)
464473

465474
if (skill.charges)
@@ -525,6 +534,7 @@ ${ Object
525534

526535
if (skills.passive && page++ == relativePage) {
527536
embed.setTitle(`${char.name}: Passives`)
537+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#${urlify(skills.passive[0].name, false)}`)
528538
for (const passive of skills.passive) {
529539
if (passive.minAscension)
530540
embed.addField(passive.name, `${passive.desc}
@@ -538,6 +548,7 @@ ${ Object
538548

539549
if (skills.constellations && page++ == relativePage) {
540550
embed.setTitle(`${char.name}: Constellations`)
551+
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#${urlify(skills.constellations[0].name, false)}`)
541552
.setThumbnail(`${client.data.baseURL}${skills.constellations[0]?.icon}`)
542553
let c = 0
543554
for (const constellation of skills.constellations)

src/commands/meta/help.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ ${Object.entries(categorized)
125125
${items.sort((a, b) => a.localeCompare(b)).map(cmd => `${config.prefix}${cmd}`).join(", ")}`)
126126
.join("\n")}
127127
128+
*Some commands are also available on the website <${client.data.baseURL}>
128129
*Make sure to check out \`${config.prefix}help <command name>\` for more information about a specific command, you might find some useful shortcuts/tips (like command aliases/how most search commands support fuzzy search).*
129130
*Any problems/suggestions? Check out \`${config.prefix}about\`.*${missingPerms.length > 0 ? `
130131

src/commands/misc/enemy.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import config from "../../data/config.json"
33
import client from "../../main"
44
import Command from "../../utils/Command"
55
import { CommandSource, Enemy, SendMessage } from "../../utils/Types"
6-
import { Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLinkToGuide, PAD_END, PAD_START, paginator, sendMessage, simplePaginator } from "../../utils/Utils"
6+
import { Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLinkToGuide, PAD_END, PAD_START, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
77

88
export default class EnemyCommand extends Command {
99
constructor(name: string) {
@@ -112,6 +112,7 @@ Note: this command supports fuzzy search.`,
112112

113113
const embed = new MessageEmbed()
114114
.setTitle("Enemies")
115+
.setURL(`${client.data.baseURL}enemies`)
115116
.setDescription(pages[relativePage])
116117
.setFooter(`Page ${currentPage} / ${maxPages} - See '${config.prefix}help enemy' for more info about what you can do`)
117118
.setColor(Colors.GREEN)
@@ -120,9 +121,11 @@ Note: this command supports fuzzy search.`,
120121
}
121122

122123
getMainEnemyPage(enemy: Enemy, relativePage: number, currentPage: number, maxPages: number): MessageEmbed | undefined {
123-
const guides = client.data.getGuides("enemy", enemy.name).map(({ guide, page }) => getLinkToGuide(guide, page)).join("\n")
124+
const { data } = client
125+
const guides = data.getGuides("enemy", enemy.name).map(({ guide, page }) => getLinkToGuide(guide, page)).join("\n")
124126
const embed = new MessageEmbed()
125127
.setTitle(`${enemy.name}: Basic info`)
128+
.setURL(`${data.baseURL}enemies/${urlify(enemy.name, false)}`)
126129
.setColor(Colors.AQUA)
127130
.setFooter(`Page ${currentPage} / ${maxPages}`)
128131
.setDescription(`**Type**: ${enemy.type ?? "Unknown"}${enemy.kind ? ` (${enemy.kind})` : ""}${enemy.notes ? `\n\n${enemy.notes}` : ""}`)
@@ -131,7 +134,7 @@ Note: this command supports fuzzy search.`,
131134
embed.addField("Guides", guides)
132135

133136
if (enemy.icon)
134-
embed.setThumbnail(`${client.data.baseURL}${enemy.icon}`)
137+
embed.setThumbnail(`${data.baseURL}${enemy.icon}`)
135138

136139
if (enemy.resistance)
137140
embed.addField("Resistances", `\`\`\`\n${createTable(["Pyro", "Elec", "Cryo", "Hydro", "Anemo", "Geo", "Phys", "Notes"], enemy.resistance, [PAD_START, PAD_START, PAD_START, PAD_START, PAD_START, PAD_START, PAD_START, PAD_END])}\n\`\`\``)
@@ -144,6 +147,7 @@ Note: this command supports fuzzy search.`,
144147
.setColor(Colors.AQUA)
145148
.setFooter(`Page ${currentPage} / ${maxPages}`)
146149
.setTitle(`${enemy.name}: Description`)
150+
.setURL(`${client.data.baseURL}enemies/${urlify(enemy.name, false)}`)
147151
.setDescription(enemy.desc ?? "Unavailable")
148152

149153
if (enemy.icon)

src/commands/misc/gachacalc.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import config from "../../data/config.json"
66
import { createTable, PAD_END, PAD_START, sendMessage } from "../../utils/Utils"
77
import log4js from "log4js"
88
import { CommandSource, SendMessage } from "../../utils/Types"
9+
import client from "../../main"
910

1011
const Logger = log4js.getLogger("GachaCalc")
1112

@@ -79,6 +80,7 @@ export default class GachaCalc extends Command {
7980
name,
8081
category: "Misc",
8182
help: `Calculate chance to get banner character/weapon in a certain amount of pulls.
83+
Also available online at <${client.data.baseURL}tools/gachacalc>
8284
8385
Available banners: ${Object.keys(gachas).map(x => `\`${x}\``).join(", ")}
8486
@@ -202,7 +204,8 @@ ${createTable(
202204
]),
203205
[PAD_END, PAD_START, PAD_START]
204206
)}
205-
\`\`\``)
207+
\`\`\`
208+
Web calculator (with graphs) is available on <${client.data.baseURL}tools/gachacalc>`)
206209
}
207210

208211
calcSims = memoize(this.calcSimsRegular, { max: 50 })

src/commands/misc/guide.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import config from "../../data/config.json"
33
import client from "../../main"
44
import Command from "../../utils/Command"
55
import { CommandSource, Guide, SendMessage } from "../../utils/Types"
6-
import { Colors, findFuzzy, findFuzzyBestCandidates, sendMessage, simplePaginator } from "../../utils/Utils"
6+
import { Colors, findFuzzy, findFuzzyBestCandidates, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
77

88

99
export default class GuideCommand extends Command {
@@ -88,12 +88,13 @@ Note: this command supports fuzzy search.`,
8888
}
8989

9090
getGuides(): string[] {
91-
const guides = client.data.guides
92-
.map((guide) => `**${guide.name}**:
91+
const { data } = client
92+
const guides = data.guides
93+
.map((guide) => `[**${guide.name}**](${data.baseURL}guides/${urlify(guide.name, false)}):
9394
${guide.pages.map(p => `- ${p.url ? `[${p.name}](${p.url})` : p.name}`).join("\n")}`)
9495

9596
const pages: string[] = [`**List of categories:**
96-
${client.data.guides.map((guide) => `- *${guide.name}*: ${guide.pages.length} ${guide.pages.length == 1 ? "guide" : "guides"}`).join("\n")}`]
97+
${data.guides.map((guide) => `- *${guide.name}*: ${guide.pages.length} ${guide.pages.length == 1 ? "guide" : "guides"}`).join("\n")}`]
9798

9899
let paging = "", c = 0
99100
for (const guide of guides) {
@@ -116,6 +117,7 @@ ${client.data.guides.map((guide) => `- *${guide.name}*: ${guide.pages.length} ${
116117

117118
const embed = new MessageEmbed()
118119
.setTitle("Guides")
120+
.setURL(`${client.data.baseURL}guides`)
119121
.setDescription(pages[relativePage])
120122
.setFooter(`Page ${currentPage} / ${maxPages} - Use '${config.prefix}guide <name>' to view a guide`)
121123
.setColor(Colors.GREEN)
@@ -133,6 +135,7 @@ export function getGuidePage(guide: Guide, relativePage: number, currentPage: nu
133135

134136
const embed = new MessageEmbed()
135137
.setTitle(page.name)
138+
.setURL(`${data.baseURL}guides/${urlify(guide.name, false)}/${urlify(page.name, true)}`)
136139
.setColor(Colors.GREEN)
137140

138141
if (maxPages > 1)
@@ -141,13 +144,12 @@ export function getGuidePage(guide: Guide, relativePage: number, currentPage: nu
141144
embed.setFooter(guide.name)
142145

143146
if (page.desc)
144-
embed.setDescription(page.desc.replace(/\${(.*?)}/g, (_, name) => data.emoji(name)))
147+
embed.setDescription(page.desc.replace(/\${(.*?)}/g, (_, name) => data.emoji(name)) +
148+
(page.url ? `\n\n[View video](${page.url})` : "")
149+
)
145150

146151
if (page.img)
147152
embed.setImage(page.img)
148153

149-
if (page.url)
150-
embed.setURL(page.url)
151-
152154
return embed
153155
}

src/commands/misc/material.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import config from "../../data/config.json"
33
import client from "../../main"
44
import Command from "../../utils/Command"
55
import { CommandSource, Material, SendMessage } from "../../utils/Types"
6-
import { Bookmarkable, Colors, findFuzzyBestCandidates, getLinkToGuide, paginator, sendMessage, simplePaginator } from "../../utils/Utils"
6+
import { Bookmarkable, Colors, findFuzzyBestCandidates, getLinkToGuide, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
77

88
export default class MaterialCommand extends Command {
99
constructor(name: string) {
@@ -112,6 +112,7 @@ Note: this command supports fuzzy search.`,
112112

113113
const embed = new MessageEmbed()
114114
.setTitle("Materials")
115+
.setURL(`${client.data.baseURL}materials`)
115116
.setDescription(pages[relativePage])
116117
.setFooter(`Page ${currentPage} / ${maxPages} - See '${config.prefix}help material' for more info about what you can do`)
117118
.setColor(Colors.GREEN)
@@ -120,9 +121,11 @@ Note: this command supports fuzzy search.`,
120121
}
121122

122123
getMainMaterialPage(material: Material, relativePage: number, currentPage: number, maxPages: number): MessageEmbed | undefined {
123-
const guides = client.data.getGuides("material", material.name).map(({ guide, page }) => getLinkToGuide(guide, page)).join("\n")
124+
const { data } = client
125+
const guides = data.getGuides("material", material.name).map(({ guide, page }) => getLinkToGuide(guide, page)).join("\n")
124126
const embed = new MessageEmbed()
125127
.setTitle(`${material.name}: Basic info`)
128+
.setURL(`${data.baseURL}materials/${urlify(material.name, false)}`)
126129
.setColor(Colors.AQUA)
127130
.setFooter(`Page ${currentPage} / ${maxPages}`)
128131
.setDescription(material.desc)
@@ -140,20 +143,22 @@ Note: this command supports fuzzy search.`,
140143
embed.addField("Sources", material.sources.join("\n"))
141144

142145
if (material.icon)
143-
embed.setThumbnail(`${client.data.baseURL}${material.icon}`)
146+
embed.setThumbnail(`${data.baseURL}${material.icon}`)
144147

145148
return embed
146149
}
147150

148151
getLoreMaterialPage(material: Material, relativePage: number, currentPage: number, maxPages: number): MessageEmbed | undefined {
152+
const { data } = client
149153
const embed = new MessageEmbed()
150154
.setColor(Colors.AQUA)
151155
.setFooter(`Page ${currentPage} / ${maxPages}`)
152156
.setTitle(`${material.name}: Description`)
157+
.setURL(`${data.baseURL}materials/${urlify(material.name, false)}#longdesc`)
153158
.setDescription(material.longDesc ?? "Unavailable")
154159

155160
if (material.icon)
156-
embed.setThumbnail(`${client.data.baseURL}${material.icon}`)
161+
embed.setThumbnail(`${data.baseURL}${material.icon}`)
157162

158163
return embed
159164
}

0 commit comments

Comments
 (0)