Git Product home page Git Product logo

blague.xyz's Introduction

Blague.xyz

Blague.xyz is a package to get jokes and FML easily from the Blague.xyz API.

🇬🇧 Jokes/FML in english are supported 🇫🇷 Blagues/Vie de merde en français sont supportées

Installation

$ npm install --save blague.xyz

API Token

You need an API Key to send request to the Blague.xyz API. Click here to get one.

Usage example

Jokes/Blague

const { Client } = require("blague.xyz");
const joker = new Client("API token", {
    defaultLang: "fr" // The default language for jokes and fml
});

// Gets a random joke. As no language is specified, it will use the default language of the client, "fr" in our case. 
joker.randomJoke().then((joke) => {
    console.log(joke.question); // Que dit une feuille quand elle tombe dans l'eau ?
    console.log(joke.answer); // J'ai papier
    console.log(joke.toString()); // Que dit une feuille quand elle tombe dans l'eau ?\nJ'ai papier
    console.log(joke.toDiscordSpoils()); // Que dit une feuille quand elle tombe dans l'eau ?\n\n||J'ai papier||
    console.log(joke.id); // 71
});

// Gets an english joke. If you specify a language, it will use it instead of the default language.
joker.dailyJoke("en").then((joke) => {
    console.log(joke.question); // What is the only dog you can eat ?
    console.log(joke.answer); // A Hot Dog
});

// Gets a joke with its ID
joker.getJoke(10, "fr").then((joke) => {
    console.log(joke.question); // Que dit une fleur qui a eu zéro à un contrôle ?
    console.log(joke.answer); // Qu'elle s'est plantée
});

// Gets the joke list. [premium only]
joker.listJoke().then((list) => {
    console.log(list); // [ {joke}, {joke}, {joke} ]
});

FML/VDM

const Client = require("blague.xyz");
const joker = new Client("API token", {
    defaultLang: "fr" // The default language for jokes and fml
});

// Gets a random vdm. As no language is specified, it will use the default language of the client, "fr" in our case. 
joker.randomVDM().then((vdm) => {
    console.log(vdm.content); // Aujourd'hui, j'ai acheté une voiture d'occasion à un de mes amis. Après avoir ramené la voiture à la maison et l'avoir inspectée, j'ai trouvé l'une des boucles d'oreilles de ma femme sur le siège arrière.
});

// Gets a random vdm with type "hot".
joker.randomVDM("hot").then((vdm) => {
    console.log(vdm.content); // Censured. Use the package to get some hot vdm...
});

// Gets an english fml. If you specify a language, it will use it instead of the default language.
joker.getVDM("normal", "en").then((fml) => {
    console.log(fml.content); // Today, a little girl asked me how I could be so fat and still have small boobs.
});

// Gets a vdm with its ID
joker.listVDM().then((list) => {
    console.log(list); // [ {vdm}, {vdm}, {vdm} ]
});

Links

blague.xyz's People

Contributors

androz2091 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blague.xyz's Issues

Get many random jokes

Add a new parameter to the random function like random(10);. This will returns 10 random jokes.

Update module on npm

Please update the module on npm because use old version of axios and follow-redirects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.