diff --git a/commands/price.js b/commands/price.js index c7c1c5f..4bb690e 100644 --- a/commands/price.js +++ b/commands/price.js @@ -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] }); }, }; \ No newline at end of file diff --git a/constants.js b/constants.js index 36b4cc4..b5e5fff 100644 --- a/constants.js +++ b/constants.js @@ -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);