From d829bcd89161999a6417b926435992478b8e57c8 Mon Sep 17 00:00:00 2001 From: Mestima Date: Tue, 28 Mar 2023 23:51:46 +0300 Subject: [PATCH] added fox command & api --- src/api/fox/index.js | 13 +++++++++++++ src/commands/fox/index.js | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/api/fox/index.js create mode 100644 src/commands/fox/index.js diff --git a/src/api/fox/index.js b/src/api/fox/index.js new file mode 100644 index 0000000..34d9836 --- /dev/null +++ b/src/api/fox/index.js @@ -0,0 +1,13 @@ +import axios from 'axios'; + +const fox = async () => { + return await axios.get('https://randomfox.ca/floof/') + .then((res) => { + return res.data.image; + }) + .catch((err) => { + console.log(err); + }); +}; + +export default { name: 'fox', execute: fox }; diff --git a/src/commands/fox/index.js b/src/commands/fox/index.js new file mode 100644 index 0000000..2248a79 --- /dev/null +++ b/src/commands/fox/index.js @@ -0,0 +1,13 @@ +import { SlashCommandBuilder } from 'discord.js'; + +export default { + data: new SlashCommandBuilder() + .setName('fox') + .setDescription('Get a random fox!'), + async execute(interaction, api) { + await api.get('fox')() + .then(async (res) => { + await interaction.reply(res); + }); + } +};