Fix predictions not working

This commit is contained in:
dartz 2024-07-28 20:54:40 -04:00
parent b521b034b7
commit 7028d2f23f

View file

@ -117,15 +117,15 @@ if (!config.token) {
case "predictions":
var source = i.options.get('source')?.value as string
let prediction_query = await fetch(`http://127.0.0.1:3000/api/v1/predictions/presidential/{source}`); // temp test url
let prediction_query = await fetch(`http://127.0.0.1:3000/api/v1/predictions/presidential/${source}`); // temp test url
let prediction_results = await prediction_query.json();
if (prediction_query.ok) {
if(prediction_results.presidential[source] != undefined) {
if(prediction_results[source] != undefined) {
var embed = new EmbedBuilder()
.setTitle(`${prediction_results.presidential[source][0].name}`)
.setDescription(`${prediction_results.presidential[source][0].before_biden_dropout ? ":red_circle: **NOTE**: This prediction was done BEFORE Joe Biden dropped out of the race. It may not reflect the current environment!\n" : ""} [Link to source](${prediction_results.presidential[source][0].url}) - last updated ${prediction_results.presidential[source][0].last_updated}\nShade is lighter based on margin of victory`)
.addFields(Object.values(prediction_results.presidential[source][0].candidates).map((candidate: any) => ({
.setTitle(`${prediction_results[source][0].name}`)
.setDescription(`${prediction_results[source][0].before_biden_dropout ? ":red_circle: **NOTE**: This prediction was done BEFORE Joe Biden dropped out of the race. It may not reflect the current environment!\n" : ""} [Link to source](${prediction_results[source][0].url}) - last updated ${prediction_results[source][0].last_updated}\nShade is lighter based on margin of victory`)
.addFields(Object.values(prediction_results[source][0].candidates).map((candidate: any) => ({
name: `${candidate.winner ? ":white_check_mark:" : ""} ${CandidateEmojis[candidate.party] ?? ""} ${candidate.name} ${candidate.incumbent ? "(I)" : ""} (${candidate.party})`,
value: `${candidate.electoral_votes} electoral votes`,
inline: true