nidhishpackage
Version:
This is a fun package for [Discord](https://discord.com) The library is [Discord.js](https://discord.js.org)
26 lines (22 loc) • 751 B
JavaScript
async function getjoke(options = {}) {
const Fetch = require(`node-fetch`)
const res = await Fetch("http://official-joke-api.appspot.com/random_joke"),
json = await res.json();
if (!json.setup || !json.punchline) throw new Error(`Something Went Wrong, Try Again Later!`);
const Data = {
embed: {
color: options.Color || "RANDOM",
title: json.setup,
description: `||${json.punchline}||`,
timestamp: new Date()
}
};
if (options.ResultOnly && options.ResultOnly === true) return {
Result: {
Setup: json.setup,
PunchLine: json.punchline
}
};
return Data;
};
module.exports = getjoke