added comprobation for discord length limit

This commit is contained in:
2023-01-14 20:20:37 -03:00
parent f36060498e
commit 205b865592
2 changed files with 11 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ const countryData = {
const pages = Object.values(countryData).map((country) => country.pages).flat(1);
const ELEMENTS_LIMIT = 3;
const DISCORD_MESSAGE_LENGTH_LIMIT = 2000;
module.exports = {
data: new SlashCommandSubcommandBuilder()
@@ -207,6 +208,11 @@ module.exports = {
pagesWithErrorScrapping.length &&
`${responses(userLanguage).errorScrapping} ${pagesWithErrorScrapping.map((name) => name).join(' ')}`,
].filter(a => a);
await interaction.editReply({ content: replyTexts.join('\n\n'), components: [...buttons] });
const response = replyTexts.join('\n\n');
let content;
if (response.length >= DISCORD_MESSAGE_LENGTH_LIMIT) {
content = responses(userLanguage).discordMessageLengthLimit;
}
await interaction.editReply({ content, components: [...buttons] });
},
};

View File

@@ -33,6 +33,10 @@ const responsesTexts = {
'en-US': 'Links aren\'t allowed :/',
'es-ES': 'No esta permitido enviar links :/',
},
discordMessageLengthLimit: {
'en-US': 'Sorry, the links of this product exceeds the limit of characters by discord message.\n\nPlease try again with a lower quantity of results.',
'es-ES': 'Lo sentimos, los enlaces de este producto exceden el límite de caracteres por mensaje de discord.\n\nPor favor, intente nuevamente con una menor cantidad de resultados.',
},
};
function responses(userLanguage) {
const responsesEntries = Object.entries(responsesTexts);