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