Skip to content

Commit aff1ddf

Browse files
committed
Fix external image icons
1 parent dd80883 commit aff1ddf

6 files changed

Lines changed: 26 additions & 21 deletions

File tree

src/commands/artifacts/artifact.ts

Lines changed: 3 additions & 3 deletions
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, urlify } from "../../utils/Utils"
5+
import { Colors, createTable, findFuzzyBestCandidates, getLink, getLinkToGuide, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
66
import { Artifact, CommandSource, SendMessage } from "../../utils/Types"
77
import config from "../../data/config.json"
88

@@ -115,7 +115,7 @@ Note: this command supports fuzzy search.`,
115115
const { data } = client
116116
const embed = new MessageEmbed()
117117
.setColor(Colors.AQUA)
118-
.setThumbnail(`${data.baseURL}${set.artis.find(x => x.icon)?.icon ?? "img/unknown.png"}`)
118+
.setThumbnail(getLink(set.artis.find(x => x.icon)?.icon ?? "img/unknown.png"))
119119
.setURL(`${data.baseURL}artifacts/${urlify(set.name, false)}`)
120120
.setFooter(`Page ${currentPage} / ${maxPages}`)
121121

@@ -152,7 +152,7 @@ ${createTable(
152152
\`\`\`
153153
154154
*See \`${config.prefix}artifact-levels <main stat> [stars = 5]\` for more info about artifact main stats*`)
155-
.setThumbnail(`${data.baseURL}${arti.icon}`)
155+
.setThumbnail(getLink(arti.icon))
156156

157157
return embed
158158
}

src/commands/characters/character.ts

Lines changed: 7 additions & 7 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, urlify } from "../../utils/Utils"
6+
import { addArg, Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLink, getLinkToGuide, PAD_END, PAD_START, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
77

88

99
const elementTypes = client.data.getCharacters()
@@ -220,7 +220,7 @@ Note: this command supports fuzzy search.`,
220220
.setFooter(`Page ${currentPage} / ${maxPages}`)
221221

222222
if (char.icon)
223-
embed.setThumbnail(`${data.baseURL}${char.icon}`)
223+
embed.setThumbnail(getLink(char.icon))
224224

225225
if (relativePage == 0) {
226226
embed.setTitle(`${char.name}: Description`)
@@ -370,7 +370,7 @@ Note: this command supports fuzzy search.`,
370370
const { data } = client
371371
const embed = new MessageEmbed()
372372
.setColor(Colors[char.meta.element] ?? "")
373-
.setThumbnail(`${data.baseURL}${char.icon}`)
373+
.setThumbnail(getLink(char.icon))
374374
.setFooter(`Page ${currentPage} / ${maxPages}`)
375375

376376
if (relativePage == 0) {
@@ -436,7 +436,7 @@ Note: this command supports fuzzy search.`,
436436
.setTitle(`${char.name}`)
437437
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#videos`)
438438
if (char.icon)
439-
embed.setThumbnail(`${data.baseURL}${char.icon}`)
439+
embed.setThumbnail(getLink(char.icon))
440440

441441
const videos = char.media.videos ? (`**Promotional Videos**
442442
${ Object
@@ -464,7 +464,7 @@ ${ Object
464464
.setFooter(`Page ${currentPage} / ${maxPages}`)
465465

466466
if (char.icon)
467-
embed.setThumbnail(`${data.baseURL}${char.icon}`)
467+
embed.setThumbnail(getLink(char.icon))
468468

469469
function isValueTable(talent: TalentTable | TalentValue): talent is TalentTable {
470470
return (talent as TalentTable).values != undefined
@@ -514,7 +514,7 @@ ${ Object
514514
else if (hasLevels && talentMode == "LITTLE")
515515
embed.setFooter(`${embed.footer?.text} - Use '${config.prefix}c ${char.name} -high' (or -low) to display higher (or lower) levels`)
516516

517-
if (skill.video) {
517+
if (skill.video && talentMode == "LITTLE") {
518518
embed.setImage(skill.video)
519519
.setThumbnail("")
520520
}
@@ -553,7 +553,7 @@ ${ Object
553553
if (skills.constellations && page++ == relativePage) {
554554
embed.setTitle(`${char.name}: Constellations`)
555555
.setURL(`${data.baseURL}characters/${urlify(char.name, false)}#${urlify(skills.constellations[0].name, false)}`)
556-
.setThumbnail(`${client.data.baseURL}${skills.constellations[0]?.icon}`)
556+
.setThumbnail(getLink(skills.constellations[0]?.icon))
557557
let c = 0
558558
for (const constellation of skills.constellations)
559559
embed.addField(`C${++c}: ${constellation.name}`, constellation.desc)

src/commands/misc/enemy.ts

Lines changed: 3 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, urlify } from "../../utils/Utils"
6+
import { Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLink, getLinkToGuide, PAD_END, PAD_START, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
77

88
export default class EnemyCommand extends Command {
99
constructor(name: string) {
@@ -134,7 +134,7 @@ Note: this command supports fuzzy search.`,
134134
embed.addField("Guides", guides)
135135

136136
if (enemy.icon)
137-
embed.setThumbnail(`${data.baseURL}${enemy.icon}`)
137+
embed.setThumbnail(getLink(enemy.icon))
138138

139139
if (enemy.resistance)
140140
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\`\`\``)
@@ -151,7 +151,7 @@ Note: this command supports fuzzy search.`,
151151
.setDescription(enemy.desc ?? "Unavailable")
152152

153153
if (enemy.icon)
154-
embed.setThumbnail(`${client.data.baseURL}${enemy.icon}`)
154+
embed.setThumbnail(getLink(enemy.icon))
155155

156156
return embed
157157
}

src/commands/misc/material.ts

Lines changed: 3 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 { Character, CommandSource, Material, SendMessage, Weapon } from "../../utils/Types"
6-
import { Bookmarkable, Colors, findFuzzyBestCandidates, getLinkToGuide, joinMulti, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
6+
import { Bookmarkable, Colors, findFuzzyBestCandidates, getLink, getLinkToGuide, joinMulti, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
77

88
export default class MaterialCommand extends Command {
99
constructor(name: string) {
@@ -214,7 +214,7 @@ Note: this command supports fuzzy search.`,
214214
embed.addField("Used by", usedByDesc.join("\n"))
215215

216216
if (material.icon)
217-
embed.setThumbnail(`${data.baseURL}${material.icon}`)
217+
embed.setThumbnail(getLink(material.icon))
218218

219219
return embed
220220
}
@@ -229,7 +229,7 @@ Note: this command supports fuzzy search.`,
229229
.setDescription(material.longDesc ?? "Unavailable")
230230

231231
if (material.icon)
232-
embed.setThumbnail(`${data.baseURL}${material.icon}`)
232+
embed.setThumbnail(getLink(material.icon))
233233

234234
return embed
235235
}

src/commands/weapons/weapon.ts

Lines changed: 5 additions & 5 deletions
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 { addArg, Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLinkToGuide, PAD_START, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
5+
import { addArg, Bookmarkable, Colors, createTable, findFuzzyBestCandidates, getLink, getLinkToGuide, PAD_START, paginator, sendMessage, simplePaginator, urlify } from "../../utils/Utils"
66
import { CommandSource, SendMessage, Weapon } from "../../utils/Types"
77
import config from "../../data/config.json"
88

@@ -209,7 +209,7 @@ Note: this command supports fuzzy search.`,
209209
.setTitle(`${weapon.name}: Basic info`)
210210
.setURL(`${data.baseURL}weapons/${urlify(weapon.name, false)}`)
211211
.setColor(Colors.AQUA)
212-
.setThumbnail(`${data.baseURL}${weapon.icon}`)
212+
.setThumbnail(getLink(weapon.icon))
213213
.setFooter(`Page ${currentPage} / ${maxPages}`)
214214
.setDescription((weapon.desc ? weapon.desc : "") + ((weapon.placeholder || !weapon.desc) ? "\n\n*This weapon is currently not yet available.*" : ""))
215215
.addField("Basics", `${weapon.stars}${data.emoji(weapon.weaponType)}`, (weapon.placeholderStats && !weapon.weaponCurve) ? true : false)
@@ -256,7 +256,7 @@ Note: this command supports fuzzy search.`,
256256
const { data } = client
257257
const embed = new MessageEmbed()
258258
.setColor(Colors.AQUA)
259-
.setThumbnail(`${data.baseURL}${weapon.icon}`)
259+
.setThumbnail(getLink(weapon.icon))
260260
.setFooter(`Page ${currentPage} / ${maxPages}`)
261261

262262
const columns: string[] = []
@@ -301,7 +301,7 @@ Note: this command supports fuzzy search.`,
301301
const { data } = client
302302
const embed = new MessageEmbed()
303303
.setColor(Colors.AQUA)
304-
.setThumbnail(`${data.baseURL}${weapon.icon}`)
304+
.setThumbnail(getLink(weapon.icon))
305305
.setFooter(`Page ${currentPage} / ${maxPages}`)
306306

307307
embed.setTitle(`${weapon.name}: Refinements`)
@@ -316,7 +316,7 @@ Note: this command supports fuzzy search.`,
316316
const { data } = client
317317
const embed = new MessageEmbed()
318318
.setColor(Colors.AQUA)
319-
.setThumbnail(`${data.baseURL}${weapon.icon}`)
319+
.setThumbnail(getLink(weapon.icon))
320320
.setFooter(`Page ${currentPage} / ${maxPages}`)
321321
.setTitle(`${weapon.name}: Lore`)
322322
.setURL(`${data.baseURL}weapons/${urlify(weapon.name, false)}#lore`)

src/utils/Utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ export function parseDuration(time: string): number {
610610
return duration
611611
}
612612

613+
export function getLink(url: string): string {
614+
if (url.match(/^https?:\/\//))
615+
return url
616+
return `${client.data.baseURL}${url}`
617+
}
613618

614619
export function getLinkToGuide(guide: Guide, page: GuidePage): string {
615620
return `[${page.name}](${client.data.baseURL}guides/${urlify(guide.name, false)}/${urlify(page.name, true)})`

0 commit comments

Comments
 (0)