3.0.0 • Published 2 years ago

@aahlw/jijitsu v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Jijitsu

Purpose: This module was created to scrape the facts provided by the official Snapple website.

Source: Real Facts by Snapple

Install

$ npm install jijitsu

Import

You can import the module itself or deconstruct the getFact function, either of the following is a vaild import:

const getFact = require('jijitsu');

const { getFact } = require('jijitsu');

Usage

Example code can be located in the test.js file.

const { getFact } = require('jijitsu');
(async _ => console.log(await getFact()))();

// Response:
{
  value: 779,
  fact: 'A group of jellyfish is called a smack.',
  url: 'https://www.snapple.com/real-facts/779',
  ping: 512
}

Explanation

{ 
    value: 779, // Fact Number (Number)
    fact: 'A group of jellyfish is called a smack.', // Fact Text (String)
    url: 'https://www.snapple.com/real-facts/779', // Fact URL (String)
    ping: 512 // Scrape and parse process time (Number)
}

Example

The following example is very oversimplied but gives a rough idea on how to implement it in your discord.js v13 bot:

const { getFact } = require('jijitsu');

<Client>.on('messageCreate', async message => {
    if (message.content = '!fact') {
        let newFact = await getFact();
        message.channel.send(`Fact #${newFact.value}: ${newFact.fact}`);
        // Fact #779: A group of jellyfish is called a smack.
    }
});