Fixed MLP char alias + result msg changes

This commit is contained in:
Lucas Gabriel 2024-10-25 10:25:07 -03:00
parent 4fcd24f025
commit 93f7e2ef21
No known key found for this signature in database
GPG key ID: D9B075FC6DC93985
4 changed files with 16 additions and 7 deletions

View file

@ -40,9 +40,18 @@ module.exports = (bot) => {
if (Array.isArray(response.data.data)) {
response.data.data.forEach(character => {
let aliases = [];
if (character.alias) {
if (typeof character.alias === 'string') {
aliases.push(character.alias);
} else if (Array.isArray(character.alias)) {
aliases = aliases.concat(character.alias);
}
}
charactersArray.push({
name: character.name,
alias: character.alias ? character.alias.join(', ') : 'N/A',
alias: aliases.length > 0 ? aliases.join(', ') : 'N/A',
url: character.url,
sex: character.sex,
residence: character.residence ? character.residence.replace(/\n/g, ' / ') : 'N/A',
@ -84,7 +93,7 @@ module.exports = (bot) => {
});
};
});
bot.command("mlpep", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
const userInput = ctx.message.text.split(' ').slice(1).join(' ');
@ -96,7 +105,7 @@ module.exports = (bot) => {
});
return;
};
const apiUrl = `http://ponyapi.net/v1/episode/by-overall/${userInput}`;
try {