we can save an api call here
This commit is contained in:
parent
a5e824d5f0
commit
b7033305ec
1 changed files with 13 additions and 9 deletions
22
src/index.ts
22
src/index.ts
|
@ -76,19 +76,23 @@ if (!config.token) {
|
|||
inline: true
|
||||
})))
|
||||
.setTimestamp();
|
||||
|
||||
const map = await fetch(`http://127.0.0.1:3000/api/v1/election/${country}/${election_type}/${year}/map`); // temp test url
|
||||
if (map.ok) {
|
||||
const arrayBuffer = await map.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
embed.setImage("attachment://map.png");
|
||||
await i.editReply({embeds: [embed], files: [{attachment: buffer, name: "map.png"}]});
|
||||
break;
|
||||
|
||||
if(results[year][0].has_map === true) {
|
||||
const map = await fetch(`http://127.0.0.1:3000/api/v1/election/${country}/${election_type}/${year}/map`); // temp test url
|
||||
if (map.ok) {
|
||||
const arrayBuffer = await map.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
embed.setImage("attachment://map.png");
|
||||
await i.editReply({embeds: [embed], files: [{attachment: buffer, name: "map.png"}]});
|
||||
break;
|
||||
} else {
|
||||
await i.editReply({embeds: [embed]});
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
await i.editReply({embeds: [embed]});
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
await i.editReply("Election not found");
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue