diff --git a/README.md b/README.md index 1bb9519..e5ff2fe 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ForestBot relies heavily on https://github.com/ForestB0T/hub ## Usage -To use ForestBot, head to the ForestBot website and reqeust him for your Minecraft Server +To use ForestBot, head to the ForestBot website and request him for your active playerbase Minecraft Server You can view your stats and learn more by visiting the ForestBot website at https://forestbot.org. diff --git a/src/commands/joke.ts b/src/commands/joke.ts new file mode 100644 index 0000000..a21a91a --- /dev/null +++ b/src/commands/joke.ts @@ -0,0 +1,27 @@ +import axios from 'axios'; //requires the axios package +import { ForestBotApiClient } from 'forestbot-api'; +import type Bot from '../structure/mineflayer/Bot.js'; +import { config } from '../config.js'; + +export default { + commands: ['joke'], + description: `Use ${config.prefix}joke to get a random joke message.`, + minArgs: 0, + maxArgs: 2, + execute: async (user, args, bot, api) => { + try { + const response = await axios.get('https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit&type=single'); + + const joke = response.data.joke; + + if (joke) { + bot.bot.chat(`Random Joke: ${joke}`); + } else { + bot.bot.chat('Sorry, something went wrong. Try again later.'); + } + } catch (error) { + console.error('Error fetching joke:', error.message); + bot.bot.chat('Sorry, something went wrong. Try again later.'); + } + }, +} as MCommand;