Compare commits
2 commits
a5e824d5f0
...
1c82c1d5ca
Author | SHA1 | Date | |
---|---|---|---|
|
1c82c1d5ca | ||
|
b7033305ec |
1 changed files with 14 additions and 10 deletions
24
src/index.ts
24
src/index.ts
|
@ -72,23 +72,27 @@ if (!config.token) {
|
||||||
.setDescription("API test")
|
.setDescription("API test")
|
||||||
.addFields(Object.values(results[year][0].candidates).map((candidate: any) => ({
|
.addFields(Object.values(results[year][0].candidates).map((candidate: any) => ({
|
||||||
name: `${candidate.winner ? ":white_check_mark:" : ""} ${CandidateEmojis[candidate.party] ?? ""} ${candidate.name} ${candidate.incumbent ? "(I)" : ""} (${candidate.party})`,
|
name: `${candidate.winner ? ":white_check_mark:" : ""} ${CandidateEmojis[candidate.party] ?? ""} ${candidate.name} ${candidate.incumbent ? "(I)" : ""} (${candidate.party})`,
|
||||||
value: `${candidate.votes.toLocaleString()} votes (${candidate.percent}%)`,
|
value: `${results[year][0].election_type === "electoral" ? `${candidate.electoral_votes} electoral votes\n` : ""} ${candidate.votes.toLocaleString()} votes (${candidate.percent}%)`,
|
||||||
inline: true
|
inline: true
|
||||||
})))
|
})))
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
const map = await fetch(`http://127.0.0.1:3000/api/v1/election/${country}/${election_type}/${year}/map`); // temp test url
|
if(results[year][0].has_map === true) {
|
||||||
if (map.ok) {
|
const map = await fetch(`http://127.0.0.1:3000/api/v1/election/${country}/${election_type}/${year}/map`); // temp test url
|
||||||
const arrayBuffer = await map.arrayBuffer();
|
if (map.ok) {
|
||||||
const buffer = Buffer.from(arrayBuffer);
|
const arrayBuffer = await map.arrayBuffer();
|
||||||
embed.setImage("attachment://map.png");
|
const buffer = Buffer.from(arrayBuffer);
|
||||||
await i.editReply({embeds: [embed], files: [{attachment: buffer, name: "map.png"}]});
|
embed.setImage("attachment://map.png");
|
||||||
break;
|
await i.editReply({embeds: [embed], files: [{attachment: buffer, name: "map.png"}]});
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
await i.editReply({embeds: [embed]});
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await i.editReply({embeds: [embed]});
|
await i.editReply({embeds: [embed]});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
await i.editReply("Election not found");
|
await i.editReply("Election not found");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue