You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.0 KiB
59 lines
2.0 KiB
require('dotenv').config();
|
|
|
|
const Discord = require('discord.js');
|
|
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
|
|
|
|
const axios = require('axios');
|
|
|
|
const slashcommands = require('./config/slash.json');
|
|
const authors = require('./config/authors.json');
|
|
|
|
client.on("ready", () => {
|
|
console.log(`Running at ${client.user.tag}!`);
|
|
});
|
|
|
|
client.on("messageCreate", async message => {
|
|
if (message.author.bot) return;
|
|
if (message.channel.type === "DM") return;
|
|
if (authors.includes(message.author.id) && message.content.toLowerCase() === "j.deploy") {
|
|
console.log("Updating slash commands...");
|
|
client.application.commands.set(slashcommands);
|
|
}
|
|
if (message.content.toLowerCase().includes("-ass ")) {
|
|
const rearrangedMessage = message.content.toLowerCase().replace(/\-ass\ /g, " ass-");
|
|
message.delete();
|
|
message.channel.createWebhook(message.author.username, { avatar: message.author.displayAvatarURL() })
|
|
.then(async webhook => {
|
|
await webhook.send({ content: rearrangedMessage });
|
|
await webhook.delete();
|
|
})
|
|
}
|
|
});
|
|
|
|
client.on("interactionCreate", async interaction => {
|
|
if (interaction.isCommand()) {
|
|
if (interaction.commandName === "joke") {
|
|
jokeCommand(interaction);
|
|
}
|
|
}
|
|
});
|
|
|
|
const jokeCommand = async interaction => {
|
|
interaction.deferReply();
|
|
let category;
|
|
interaction.options.get("category") ? category = interaction.options.get("category").value : category = "Any";
|
|
axios.get(`https://v2.jokeapi.dev/joke/${category}?blacklistFlags=nsfw,religious,political,racist,sexist,explicit`)
|
|
.then(async response => {
|
|
const data = response.data;
|
|
const jokeEmbed = new Discord.MessageEmbed().setAuthor(`Category: ${data.category}`);
|
|
if (data.type === "single") {
|
|
jokeEmbed.setDescription(data.joke);
|
|
} else if (data.type === "twopart") {
|
|
jokeEmbed.setTitle(data.setup);
|
|
jokeEmbed.setDescription(`||${data.delivery}||`);
|
|
}
|
|
await interaction.followUp({ embeds: [jokeEmbed] });
|
|
});
|
|
}
|
|
|
|
client.login(process.env.TOKEN);
|
|
|