Parent Directory
|
Revision Log
Release version 1.10.0 * Added -queues command to list all queued jobs * Added -joke command to fetch random jokes * Added support of user tags in some user-based commands
1 | const { default: axios } = require("axios"); |
2 | const { MessageEmbed } = require("discord.js"); |
3 | |
4 | module.exports = { |
5 | async handle(msg, cm) { |
6 | axios.get("https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist", { |
7 | headers: { |
8 | 'Accept': 'application/json' |
9 | } |
10 | }) |
11 | .then(async res => { |
12 | if (res.data && !res.data.error) { |
13 | await msg.reply({ |
14 | embeds: [ |
15 | new MessageEmbed() |
16 | .setColor('#007bff') |
17 | .setTitle('Joke') |
18 | .setDescription(res.data.type === 'twopart' ? res.data.setup + '\n\n' + res.data.delivery : res.data.joke) |
19 | .addField('Category', res.data.category) |
20 | .setFooter({ |
21 | text: `ID: ${res.data.id}` |
22 | }) |
23 | ] |
24 | }); |
25 | } |
26 | else { |
27 | await msg.reply({ |
28 | content: "Something went wrong with the API response. Please try again later." |
29 | }); |
30 | } |
31 | }) |
32 | .catch(async e => { |
33 | console.log(e); |
34 | await msg.reply({ |
35 | content: "Something went wrong with the API. Please try again later." |
36 | }); |
37 | }) |
38 | } |
39 | }; |
[email protected] | ViewVC Help |
Powered by ViewVC 1.1.26 |