Use embedURL when relevant

This commit is contained in:
Dragon Fire
2024-05-13 23:47:28 -04:00
parent 456281576b
commit 44f51bd219
9 changed files with 22 additions and 13 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ const { stripIndents } = require('common-tags');
const request = require('node-superfetch');
const cheerio = require('cheerio');
const { decode: decodeHTML } = require('html-entities');
const { firstUpperCase } = require('../../util/Util');
const { firstUpperCase, embedURL } = require('../../util/Util');
const { months } = require('../../assets/json/month');
module.exports = class FloridaManCommand extends Command {
@@ -48,7 +48,7 @@ module.exports = class FloridaManCommand extends Command {
return msg.say(stripIndents`
**${article.title}**
${firstUpperCase(months[month - 1])} ${day}${article.firstLine}
[Read more...](<https://floridamanbirthday.org/${months[month - 1]}-${day}>)
${embedURL('Read more...', `<https://floridamanbirthday.org/${months[month - 1]}-${day}>`)}
`, { files: [article.image] });
}
+2 -1
View File
@@ -1,5 +1,6 @@
const Command = require('../../framework/Command');
const { EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { embedURL } = require('../../util/Util');
module.exports = class FirstMessageCommand extends Command {
constructor(client) {
@@ -33,7 +34,7 @@ module.exports = class FirstMessageCommand extends Command {
.setDescription(message.content || 'No content.')
.setTimestamp(message.createdAt)
.setFooter({ text: `ID: ${message.id}` })
.addField(' Jump', `[Click Here to Jump](${message.url})`);
.addField(' Jump', embedURL('Click Here to Jump', message.url));
return msg.embed(embed);
}
};
+3 -1
View File
@@ -1,5 +1,6 @@
const Command = require('../../framework/Command');
const { EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { embedURL } = require('../../util/Util');
const genGames = [null, 'rb', 'gs', 'rs', 'dp', 'bw', 'xy', 'sm', 'ss', 'sv'];
const games = {
rb: 'Red/Blue',
@@ -71,7 +72,8 @@ module.exports = class SmogonCommand extends Command {
})
.setThumbnail(pokemon.spriteImageURL);
for (const game of fetchGames) {
embed.addField(` ${games[game]}`, `[${pokemon.smogonTiers[game].join('/')}](${pokemon.smogonURL(game)})`, true);
const tiers = pokemon.smogonTiers[game];
embed.addField(` ${games[game]}`, embedURL(tiers.join('/'), pokemon.smogonURL(game)), true);
}
if (fetchGames.length % 3 !== 0 && fetchGames.length > 3) {
for (let i = 0; i < 3 - (fetchGames.length % 3); i++) {
+4 -1
View File
@@ -1,6 +1,7 @@
const Command = require('../../framework/Command');
const { PermissionFlagsBits } = require('discord.js');
const sagiri = require('sagiri');
const { embedURL } = require('../../util/Util');
const { SAUCENAO_KEY } = process.env;
const sagiriClient = sagiri(SAUCENAO_KEY);
const fs = require('fs');
@@ -58,7 +59,9 @@ module.exports = class XiaoCommand extends Command {
if (data && data[0].similarity > 90) {
result = '';
const sauce = data[0];
if (sauce.authorName && sauce.authorUrl) result += `Art by [${sauce.authorName}](<${sauce.authorUrl}>) | `;
if (sauce.authorName && sauce.authorUrl) {
result += `Art by ${embedURL(sauce.authorName, `<${sauce.authorUrl}>`)} | `;
}
if (sauce.authorName && !sauce.authorUrl) result += `Art by ${sauce.authorName} | `;
result += `Art Source: <${sauce.url}>`;
}
+1 -1
View File
@@ -132,7 +132,7 @@ module.exports = class AnimeCommand extends Command {
.addField(` MAL Score`, malScore ? embedURL(malScore, malURL) : '???', true)
.addField(` ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '???', true)
.addField(' External Links', anime.externalLinks.length
? anime.externalLinks.map(link => `[${link.site}](${link.url})`).join(', ')
? anime.externalLinks.map(link => embedURL(link.site, link.url)).join(', ')
: 'None');
return msg.embed(embed);
}
+3 -2
View File
@@ -2,6 +2,7 @@ const Command = require('../../framework/Command');
const request = require('node-superfetch');
const { EmbedBuilder } = require('discord.js');
const { stripIndents } = require('common-tags');
const { embedURL } = require('../../util/Util');
const logos = require('../../assets/json/logos');
module.exports = class MagicCommand extends Command {
@@ -75,8 +76,8 @@ module.exports = class MagicCommand extends Command {
embed.addField(' Loyalty', card.loyalty);
}
embed.addField(' Price', stripIndents`
**Non-Foil:** [${card.prices.usd ? `$${card.prices.usd}` : '???'}](${card.purchase_uris.tcgplayer})
**Foil:** [${card.prices.usd_foil ? `$${card.prices.usd_foil}` : '???'}](${card.purchase_uris.tcgplayer})
**Non-Foil:** ${embedURL(card.prices.usd ? `$${card.prices.usd}` : '???', card.purchase_uris.tcgplayer)}
**Foil:** ${embedURL(card.prices.usd_foil ? `$${card.prices.usd_foil}` : '???', card.purchase_uris.tcgplayer)}
`);
return msg.embed(embed);
}
+1 -1
View File
@@ -125,7 +125,7 @@ module.exports = class MangaCommand extends Command {
.addField(` MAL Score`, malScore ? embedURL(malScore, malURL) : '???', true)
.addField(` ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '???', true)
.addField(' External Links', manga.externalLinks.length
? manga.externalLinks.map(link => `[${link.site}](${link.url})`).join(', ')
? manga.externalLinks.map(link => embedURL(link.site, link.url)).join(', ')
: 'None');
return msg.embed(embed);
}
+2 -1
View File
@@ -1,6 +1,7 @@
const Command = require('../../framework/Command');
const { EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const request = require('node-superfetch');
const { embedURL } = require('../../util/Util');
const logos = require('../../assets/json/logos');
module.exports = class WikipediaCommand extends Command {
@@ -67,7 +68,7 @@ module.exports = class WikipediaCommand extends Command {
fact += ' ';
}
const url = `https://en.wikipedia.org/wiki/${encodeURIComponent(query).replaceAll(')', '%29')}`;
fact += `[Read more...](${url})`;
face += embedURL('Read more...', url);
const embed = new EmbedBuilder()
.setColor(0xE7E7E7)
.setTitle(data.title)
+4 -3
View File
@@ -1,4 +1,5 @@
const Command = require('../../framework/Command');
const { embedURL } = require('../../util/Util');
const { dependencies, optionalDependencies } = require('../../package');
const deps = Object.keys({ ...dependencies, ...optionalDependencies }).sort();
@@ -17,7 +18,7 @@ module.exports = class GenerateCreditCommand extends Command {
}
async run(msg) {
const npm = `* ${deps.map(dep => `[${dep}](https://www.npmjs.com/package/${dep})`).join('\n* ')}`;
const npm = `* ${deps.map(dep => embedURL(dep, `https://www.npmjs.com/package/${dep}`)).join('\n* ')}`;
const list = this.client.registry.groups
.map(g => {
const commands = g.commands
@@ -28,8 +29,8 @@ module.exports = class GenerateCreditCommand extends Command {
const credits = c.credit
.filter(cred => cred.name !== 'Dragon Fire')
.map(cred => {
const reason = cred.reasonURL ? `[${cred.reason}](${cred.reasonURL})` : cred.reason;
return `[${cred.name}](${cred.url}) (${reason})`;
const reason = cred.reasonURL ? embedURL(cred.reason, cred.reasonURL) : cred.reason;
return `${embedURL(cred.name, cred.url)} (${reason})`;
});
return `* **${c.name}:**\n - ${credits.join('\n - ')}`;
}).join('\n');