From f76aa35692640cd3b5e36d241ba6a95a712755e5 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sun, 16 May 2021 09:30:05 -0500 Subject: [PATCH] Add ISS to slash commands --- bot/awesomescibo.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bot/awesomescibo.js b/bot/awesomescibo.js index 908c39f..32364a2 100755 --- a/bot/awesomescibo.js +++ b/bot/awesomescibo.js @@ -336,11 +336,11 @@ function showServerNumber(message) { message.channel.send(client.guilds.cache.size); } -async function showIssLocation(message) { +async function showIssLocation(interaction) { await fetch("http://api.open-notify.org/iss-now.json") .then((request) => request.json()) .then((data) => { - message.channel.send( + interaction.reply( new Discord.MessageEmbed() .setTitle("The current location of the ISS!") .setImage( @@ -348,7 +348,7 @@ async function showIssLocation(message) { ) .setURL("https://spotthestation.nasa.gov/tracking_map.cfm") ); - }); + }).catch(error => { if (error) interaction.editReply("Unable to fetch data. Please try again!") }); } function showLeaderboard(interaction) { @@ -488,14 +488,6 @@ async function rounds(action, interaction) { } } -async function hits(message) { - let totalCount = await generatedRound.countDocuments({}); - let userCount = await generatedRound.countDocuments({ requestedBy: message.author.id }); - - message.channel.send(`Total Hits: ${totalCount}\nYour Hits: ${userCount}`); -} - - client.on("message", async (message) => { if (message.author.bot) { return; @@ -539,6 +531,10 @@ client.on("interaction", interaction => { break; case "about": about(interaction.options[0].name, interaction); + break; + case "iss": + showIssLocation(interaction); + break; } })