From 6fa17a50225fa62831ab7950219a25db48547ad5 Mon Sep 17 00:00:00 2001 From: Ayden Jahola Date: Wed, 25 Sep 2024 22:22:58 +0100 Subject: [PATCH] commands: add bored command --- commands/fun/bored.js | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 commands/fun/bored.js diff --git a/commands/fun/bored.js b/commands/fun/bored.js new file mode 100644 index 0000000..952a052 --- /dev/null +++ b/commands/fun/bored.js @@ -0,0 +1,44 @@ +const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const axios = require("axios"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("bored") + .setDescription("Get a random activity to do."), + + async execute(interaction) { + try { + const res = await axios.get("https://bored-api.appbrewery.com/random"); + + const activity = res.data.activity; + const type = res.data.type; + const accessibility = res.data.accessibility; + const duration = res.data.duration; + const kidFriendly = res.data.kidFriendly; + + const embed = new EmbedBuilder() + .setColor("#9b226a") + .setTitle("Random Activity to Do") + .addFields( + { name: "Activity", value: `${activity}` }, + { name: "Type", value: `${type}` }, + { name: "Accessibility", value: `${accessibility}` }, + { name: "Duration", value: `${duration}` }, + { name: "Kid Friendly", value: `${kidFriendly}` } + ) + + .setTimestamp() + .setFooter({ + text: interaction.guild.name, + iconURL: interaction.guild.iconURL(), + }); + + await interaction.reply({ embeds: [embed] }); + } catch (error) { + console.error(error); + await interaction.reply( + "There was an error trying to fetch a random activity." + ); + } + }, +};