No overlay for alert map, sadge

This commit is contained in:
Christopher Cookman 2024-05-19 23:50:15 -06:00
parent e60352d5c8
commit 821d6b52aa
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 34 additions and 0 deletions

View file

@ -269,5 +269,10 @@
"required": false
}
]
},
{
"name": "alertmap",
"description": "Get a map of active alerts",
"type": 1
}
]

View file

@ -1084,6 +1084,35 @@ discord.on("interactionCreate", async (interaction) => {
console.error(err);
});
break;
case "alertmap":
url = "https://www.spc.noaa.gov/products/wwa/wwa_new.gif"
await interaction.deferReply();
fetch(url).then((res) => {
if (res.status !== 200) {
interaction.editReply({ content: "Failed to get alert map", ephemeral: true });
return;
}
res.buffer().then(async (buffer) => {
interaction.editReply({
embeds: [{
title: `Alert Map`,
image: {
url: `attachment://alerts.png`
},
color: 0x00ff00
}],
files: [{
attachment: buffer,
name: `alerts}.png`
}]
});
});
}).catch((err) => {
interaction.editReply({ content: "Failed to get alert map", ephemeral: true });
console.log(`${colors.red("[ERROR]")} Failed to get alert map: ${err.message}`);
console.error(err);
});
break;
}
case Discord.InteractionType.MessageComponent:
if (interaction.customId) {