diff --git a/data/commands.json b/data/commands.json index e92b37c..73692ec 100644 --- a/data/commands.json +++ b/data/commands.json @@ -269,5 +269,10 @@ "required": false } ] + }, + { + "name": "alertmap", + "description": "Get a map of active alerts", + "type": 1 } ] \ No newline at end of file diff --git a/index.js b/index.js index c2c22b6..e4e7b28 100644 --- a/index.js +++ b/index.js @@ -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) {