mirror of
https://github.com/FranP-code/shopping-discord-bot.git
synced 2025-10-13 00:22:44 +00:00
added comprobation for discord length limit
This commit is contained in:
@@ -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] });
|
||||
},
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user