mirror of
https://github.com/FranP-code/shopping-discord-bot.git
synced 2025-10-13 00:22:44 +00:00
added customTextSuggest and some ajustments in the bot
This commit is contained in:
50
constants.js
Normal file
50
constants.js
Normal file
@@ -0,0 +1,50 @@
|
||||
require('dotenv').config();
|
||||
|
||||
const urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
|
||||
function getRandomElementFromArray(arr) {
|
||||
return arr[Math.floor((Math.random() * arr.length))];
|
||||
}
|
||||
const responsesTexts = {
|
||||
suggestionSended: {
|
||||
'en-US': `Suggestion sended to <@${process.env.MY_DISCORD_USER_ID}>`,
|
||||
'es-ES': `Sugerencia enviada a <@${process.env.MY_DISCORD_USER_ID}>`,
|
||||
},
|
||||
extractedFrom: {
|
||||
'en-US': 'Prices extracted from:',
|
||||
'es-ES': 'Precios extraídos de:',
|
||||
},
|
||||
missingPlatform: {
|
||||
'en-US': 'ERROR: Platform don\'t found!!',
|
||||
'es-ES': 'ERROR: Plataforma no encontrada!!',
|
||||
},
|
||||
platformInBrowser: {
|
||||
'en-US': 'Search in %P on browser',
|
||||
'es-ES': 'Buscar en %P en el buscador',
|
||||
},
|
||||
errorScrapping: {
|
||||
'en-US': 'No products could be found in:',
|
||||
'es-ES': 'No se pudieron encontrar productos en:',
|
||||
},
|
||||
notSuggest: {
|
||||
'en-US': 'Please suggest someting :tired_face:',
|
||||
'es-ES': 'Por favor, sugiere algo :tired_face:',
|
||||
},
|
||||
linksNotAllowed: {
|
||||
'en-US': 'Links aren\'t allowed :/',
|
||||
'es-ES': 'No esta permitido enviar links :/',
|
||||
},
|
||||
};
|
||||
function responses(userLanguage) {
|
||||
const responsesEntries = Object.entries(responsesTexts);
|
||||
const localizatedResponses = {};
|
||||
responsesEntries.forEach(([responseName, responseTexts]) => {
|
||||
localizatedResponses[responseName] = Object.entries(responseTexts).find(responseText => responseText[0] === userLanguage)[1];
|
||||
});
|
||||
return localizatedResponses;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
urlRegex,
|
||||
getRandomElementFromArray,
|
||||
responses,
|
||||
};
|
||||
Reference in New Issue
Block a user