2023-01-08 02:50:40 -05:00
|
|
|
const { EmbedBuilder } = require('discord.js');
|
|
|
|
const giveMeAJoke = require('give-me-a-joke');
|
2022-09-24 13:24:48 -04:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
name: "joke",
|
|
|
|
description: "Gets a funny joke",
|
|
|
|
|
2023-01-08 02:50:40 -05:00
|
|
|
async run(client, interaction) {
|
|
|
|
let joke = await giveMeAJoke.getRandomDadJoke();
|
2022-09-24 13:24:48 -04:00
|
|
|
|
2023-01-08 02:50:40 -05:00
|
|
|
if (joke.includes("?")){
|
|
|
|
let jokeData = joke.split("?");
|
|
|
|
joke = `${jokeData[0]}?||${jokeData[1]}||`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const embed = createJokeEmbed(joke, interaction.user);
|
|
|
|
interaction.editReply({ embeds: [embed] });
|
2022-09-24 13:24:48 -04:00
|
|
|
},
|
2023-01-08 02:50:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
function createJokeEmbed(joke, user) {
|
|
|
|
return new EmbedBuilder()
|
|
|
|
.setColor("#FF0000")
|
|
|
|
.setTitle("Here is your joke...")
|
|
|
|
.setDescription(joke)
|
|
|
|
.setTimestamp()
|
|
|
|
.setFooter({
|
|
|
|
text: `Requested by ${user.tag}`,
|
|
|
|
iconURL: user.displayAvatarURL()
|
|
|
|
});
|
|
|
|
}
|