/[sudobot]/trunk/commands/joke.js
ViewVC logotype

Contents of /trunk/commands/joke.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (show annotations)
Mon Jul 29 17:28:21 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: text/javascript
File size: 1381 byte(s)
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