added embed support to lang

This commit is contained in:
2022-02-14 14:37:10 -06:00
parent 28fb9ed3c8
commit 458d3f3d76
5 changed files with 450 additions and 57 deletions

26
dist/api.js vendored
View File

@@ -25,9 +25,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.getPlayerInteraction = exports.getPlayer = void 0;
/*eslint prefer-const: "error"*/
const cheerio = __importStar(require("cheerio"));
const discord_js_1 = require("discord.js");
const https_1 = __importDefault(require("https"));
const util_1 = require("./util");
const Lang = __importStar(require("./lang"));
const uniteApiRegex = {
//$1 = name, $2 = id
ogtitle: /unite api - (.+) \((.*)\)/i,
@@ -187,18 +187,18 @@ async function sendPlayerEmbed(interaction, data) {
eloStr = `(${data.elo})`;
else
eloStr = `Class ${data.class}`;
const embed = new discord_js_1.MessageEmbed()
.setTitle(`${data.name} (${data.id})`)
.setURL(`https://uniteapi.dev/p/${encodeURIComponent(data.name)}`)
.setTimestamp()
.setThumbnail(data.avatar)
.setDescription(`Level ${data.level}
${data.rank} ${eloStr}
**Battles** ${data.battles}
**Wins** ${data.wins}
**Win Rate** ${data.winrate}`);
await interaction.editReply({ embeds: [embed] });
await interaction.editReply(Lang.getEmbed('api.player', {
name: data.name,
id: data.id,
nameEncoded: encodeURIComponent(data.name),
avatar: data.avatar,
level: data.level,
rank: data.rank,
elo: eloStr,
battles: data.battles,
wins: data.wins,
winrate: data.winrate
}));
}
/**
* calls getPlayer() with the name from the interaction