Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Parsers/Currency Converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ var input = current.text.trim(); // Get entire user input after trimming
// Extract amount, fromCurrency, and toCurrency from the input
var match = input.match(/!convert (\d+) (\w+) to (\w+)/);
var amount = match ? match[1] : "";
var fromCurrency = match ? match[2] : "";
var toCurrency = match ? match[3] : "";
var fromCurrency = match ? match[2].toUpperCase() : "";
var toCurrency = match ? match[3].toUpperCase() : "";

// Build the search URL using the Currency Converter API
var baseUrl = 'https://api.exchangeratesapi.io/latest';
var searchUrl = baseUrl + '?base=' + fromCurrency;
var baseUrl = 'https://api.frankfurter.dev/v1/latest';
var searchUrl = baseUrl + '?base=' + fromCurrency + '&symbols=' + toCurrency;

// Make the API request
var chatReq = new sn_ws.RESTMessageV2();
Expand All @@ -34,5 +34,5 @@ if (responseData.rates && responseData.rates[toCurrency]) {
// Send a formatted message to Slack
new x_snc_slackerbot.Slacker().send_chat(current, `${amount} ${fromCurrency} is equal to ${convertedAmount.toFixed(2)} ${toCurrency}`, false);
} else {
new x_snc_slackerbot.Slacker().send_chat(current, "Sorry, I couldn't find the exchange rate for ${fromCurrency} to ${toCurrency}.", false);
new x_snc_slackerbot.Slacker().send_chat(current, "Sorry, I couldn't find the exchange rate for " + fromCurrency + " to " + toCurrency + ".", false);
}
Loading