-
Notifications
You must be signed in to change notification settings - Fork 0
Facts
This bot has got many facts waiting for you. If you ever want to impress someone with a random fact this bot has got you covered. With data from the meow facts API and the random useless facts API you'll never need school books again.
With //fact you can request a random fact. This fact will be requested from the random useless facts API, and will contain a lot of random cool facts.
Use //catfact to get a fact about, you guessed it, cats. These cat facts will be requested from the meow facts API.
This functionality is not complicated.
const fetch = require('node-fetch');
const url = 'https://uselessfacts.jsph.pl/random.json?language=en';
Fetch gets required and the url gets defined at the top of the document.
fetch(url)
.then(res => res.json())
.then((out) => {
message.channel.send(out.text);
})
.catch(err => {
throw err
});
Then the url gets fetched. When the data is fetched it gets formatted into JSON. When that has been done the correct data gets sent to the text channel, and there is a small error catch for when something goes wrong.