rolling back to refine later
This commit is contained in:
parent
85f2d8d04a
commit
65adff92d0
@ -1,31 +1,43 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
const {
|
||||||
const giveMeAJoke = require('give-me-a-joke');
|
EmbedBuilder
|
||||||
|
} = require('discord.js');
|
||||||
|
var giveMeAJoke = require('give-me-a-joke');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "joke",
|
name: "joke",
|
||||||
description: "Gets a funny joke",
|
description: "Gets a funny joke",
|
||||||
|
|
||||||
async run(client, interaction) {
|
run: async (client, interaction) => {
|
||||||
let joke = await giveMeAJoke.getRandomDadJoke();
|
giveMeAJoke.getRandomDadJoke(function (joke) {
|
||||||
|
|
||||||
if (joke.includes("?")){
|
if (joke.includes("?")){
|
||||||
let jokeData = joke.split("?");
|
let jokeData = joke.split("?")
|
||||||
joke = `${jokeData[0]}?||${jokeData[1]}||`;
|
const embed = new EmbedBuilder()
|
||||||
}
|
.setColor("#FF0000")
|
||||||
|
.setTitle("Here is your joke...")
|
||||||
const embed = createJokeEmbed(joke, interaction.user);
|
.setDescription(jokeData[0] + "?||" + jokeData[1] + "||")
|
||||||
interaction.editReply({ embeds: [embed] });
|
.setTimestamp()
|
||||||
|
.setFooter({
|
||||||
|
text: `Requested by ${interaction.user.tag}`,
|
||||||
|
iconURL: `${interaction.user.displayAvatarURL()}`
|
||||||
|
});
|
||||||
|
interaction.editReply({
|
||||||
|
embeds: [embed]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor("#FF0000")
|
||||||
|
.setTitle("Here is your joke...")
|
||||||
|
.setDescription(joke)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter({
|
||||||
|
text: `Requested by ${interaction.user.tag}`,
|
||||||
|
iconURL: `${interaction.user.displayAvatarURL()}`
|
||||||
|
});
|
||||||
|
interaction.editReply({
|
||||||
|
embeds: [embed]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
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()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -1,40 +1,47 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
const {
|
||||||
const urban = require('urban');
|
EmbedBuilder
|
||||||
|
} = require('discord.js');
|
||||||
|
var urban = require('urban')
|
||||||
|
const isNotDefined = require("is-not-defined");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "urban",
|
name: "urban",
|
||||||
description: "Searches Urban Dictionary",
|
description: "Searches Urban Dictionary",
|
||||||
options: [{
|
options: [{
|
||||||
name: "query",
|
"name": "query",
|
||||||
description: "The thing you want to search for",
|
"description": "The thing you want to search for",
|
||||||
required: true,
|
"required": true,
|
||||||
type: 3 // 6 is type USER
|
"type": 3 // 6 is type USER
|
||||||
}],
|
}],
|
||||||
|
|
||||||
async run(client, interaction) {
|
run: async (client, interaction) => {
|
||||||
let searchWord = interaction.options._hoistedOptions[0].value;
|
|
||||||
let search = urban(searchWord);
|
|
||||||
|
|
||||||
let data = await search.first();
|
let searchWord = interaction.options._hoistedOptions[0].value
|
||||||
|
search = urban(searchWord);
|
||||||
|
|
||||||
if (data) {
|
search.first(function(data) {
|
||||||
const embed = createUrbanEmbed(data, searchWord, interaction.user);
|
|
||||||
interaction.editReply({ embeds: [embed] });
|
if (!isNotDefined(data)) {
|
||||||
} else {
|
|
||||||
interaction.editReply("Sorry, no results were found!");
|
const embed = new EmbedBuilder()
|
||||||
}
|
.setColor("#FF0000")
|
||||||
|
.setTitle("Results for: " + searchWord)
|
||||||
|
.setDescription("Definition: " + data.definition)
|
||||||
|
.addFields({
|
||||||
|
name: 'Example',
|
||||||
|
value: data.example
|
||||||
|
})
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter({
|
||||||
|
text: `Requested by ${interaction.user.tag}`,
|
||||||
|
iconURL: `${interaction.user.displayAvatarURL()}`
|
||||||
|
});
|
||||||
|
interaction.editReply({
|
||||||
|
embeds: [embed]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return interaction.editReply("Sorry, no results were found!")
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function createUrbanEmbed(data, searchWord, user) {
|
|
||||||
return new EmbedBuilder()
|
|
||||||
.setColor("#FF0000")
|
|
||||||
.setTitle(`Results for: ${searchWord}`)
|
|
||||||
.setDescription(`Definition: ${data.definition}`)
|
|
||||||
.addFields({ name: 'Example', value: data.example })
|
|
||||||
.setTimestamp()
|
|
||||||
.setFooter({
|
|
||||||
text: `Requested by ${user.tag}`,
|
|
||||||
iconURL: user.displayAvatarURL()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -4,40 +4,49 @@ module.exports = {
|
|||||||
name: "8ball",
|
name: "8ball",
|
||||||
description: "Ask a question, get a response.",
|
description: "Ask a question, get a response.",
|
||||||
options: [{
|
options: [{
|
||||||
name: "question",
|
"name": "question",
|
||||||
description: "The question you would like to ask.",
|
"description": "The question you would like to ask.",
|
||||||
required: true,
|
"required": true,
|
||||||
type: 3 // 6 is type USER
|
"type": 3 // 6 is type USER
|
||||||
}],
|
}],
|
||||||
run: async (client, interaction) => {
|
run: async (client, interaction) => {
|
||||||
let question = interaction.options._hoistedOptions[0].value;
|
let question = interaction.options._hoistedOptions[0].value
|
||||||
|
|
||||||
const responses = [
|
function send(question, message){
|
||||||
"It is certain",
|
const embed = new EmbedBuilder()
|
||||||
"It is decidedly so",
|
.setColor("#FF0000")
|
||||||
"Reply hazy try again",
|
.setTitle(question)
|
||||||
"Cannot predict now",
|
.setDescription(message)
|
||||||
"Do not count on it",
|
.setTimestamp()
|
||||||
"My sources say no",
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
"Outlook not so good",
|
|
||||||
"Signs point to yes"
|
|
||||||
];
|
|
||||||
|
|
||||||
const response = responses[Math.floor(Math.random() * responses.length)];
|
|
||||||
|
|
||||||
const embed = create8BallEmbed(question, response, interaction.user);
|
|
||||||
interaction.editReply({ embeds: [embed] });
|
interaction.editReply({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
|
||||||
|
var answer = Math.floor(Math.random() * 8);
|
||||||
|
|
||||||
|
if (answer === 0) {
|
||||||
|
send(question, "it is certain")
|
||||||
|
}
|
||||||
|
else if (answer === 1) {
|
||||||
|
send(question, "It is decidedly so");
|
||||||
|
}
|
||||||
|
else if (answer === 2) {
|
||||||
|
send(question, "Reply hazy try again");
|
||||||
|
}
|
||||||
|
else if (answer === 3) {
|
||||||
|
send(question, "Cannot predict now");
|
||||||
|
}
|
||||||
|
else if (answer === 4) {
|
||||||
|
send(question, "Do not count on it");
|
||||||
|
}
|
||||||
|
else if (answer === 5) {
|
||||||
|
send(question, "My sources say no");
|
||||||
|
}
|
||||||
|
else if (answer === 6) {
|
||||||
|
send(question, "Outlook not so good");
|
||||||
|
}
|
||||||
|
else if (answer === 7) {
|
||||||
|
send(question, "Signs point to yes");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function create8BallEmbed(question, response, user) {
|
|
||||||
return new EmbedBuilder()
|
|
||||||
.setColor("#FF0000")
|
|
||||||
.setTitle(question)
|
|
||||||
.setDescription(response)
|
|
||||||
.setTimestamp()
|
|
||||||
.setFooter({
|
|
||||||
text: `Requested by ${user.tag}`,
|
|
||||||
iconURL: user.displayAvatarURL()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -1,31 +1,26 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
const { EmbedBuilder } = require('discord.js');
|
||||||
const unirest = require('unirest');
|
var unirest = require('unirest');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "bored",
|
name: "bored",
|
||||||
description: "Find an activity to do when you are bored.",
|
description: "Find an activity to do when you are bored.",
|
||||||
|
|
||||||
async run(client, interaction) {
|
run: async (client, interaction) => {
|
||||||
let response = await unirest
|
|
||||||
|
unirest
|
||||||
.get('https://www.boredapi.com/api/activity')
|
.get('https://www.boredapi.com/api/activity')
|
||||||
.headers({
|
.headers({
|
||||||
'Accept': 'application/json', 'Content-Type': 'application/json',
|
'Accept': 'application/json', 'Content-Type': 'application/json',
|
||||||
});
|
})
|
||||||
|
.then((response) => {
|
||||||
let data = response.body;
|
let data = response.body
|
||||||
const embed = createBoredEmbed(data, interaction.user);
|
const embed = new EmbedBuilder()
|
||||||
interaction.followUp({ embeds: [embed] });
|
.setColor("#FF0000")
|
||||||
|
.setTitle("Here is something to do!")
|
||||||
|
.setDescription(data.activity)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
|
interaction.followUp({ embeds: [embed] });
|
||||||
|
})
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function createBoredEmbed(data, user) {
|
|
||||||
return new EmbedBuilder()
|
|
||||||
.setColor("#FF0000")
|
|
||||||
.setTitle("Here is something to do!")
|
|
||||||
.setDescription(data.activity)
|
|
||||||
.setTimestamp()
|
|
||||||
.setFooter({
|
|
||||||
text: `Requested by ${user.tag}`,
|
|
||||||
iconURL: user.displayAvatarURL()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
const { MessageEmbed, Attachment, TextChannel } = require('discord.js');
|
const { EmbedBuilder } = require('discord.js');
|
||||||
|
const { AttachmentBuilder } = require('discord.js');
|
||||||
const { AwesomeQR } = require("awesome-qr");
|
const { AwesomeQR } = require("awesome-qr");
|
||||||
const fs = require("fs").promises;
|
const fs = require("fs");
|
||||||
|
|
||||||
let fileName;
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "qr",
|
name: "qr",
|
||||||
@ -15,36 +14,32 @@ module.exports = {
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
run: async (client, interaction) => {
|
run: async (client, interaction) => {
|
||||||
if (!fileName) {
|
|
||||||
fileName = Math.floor(Math.random() * 99999).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const text = interaction.options._hoistedOptions[0].value;
|
(async () => {
|
||||||
const background = Buffer.from(fs.readFileSync("Terminal-icon.png"));
|
let rand = Math.floor(Math.random() * 99999).toString();
|
||||||
const buffer = await new AwesomeQR({
|
let text = interaction.options._hoistedOptions[0].value
|
||||||
text: text,
|
|
||||||
size: 500,
|
|
||||||
backgroundImage: background,
|
|
||||||
}).draw();
|
|
||||||
|
|
||||||
await fs.writeFile(`./images/${fileName}.png`, buffer);
|
const background = fs.readFileSync("Terminal-icon.png");
|
||||||
const file = new Attachment(`./images/${fileName}.png`);
|
|
||||||
|
|
||||||
const embed = new MessageEmbed()
|
const buffer = await new AwesomeQR({
|
||||||
|
text: text,
|
||||||
|
size: 500,
|
||||||
|
backgroundImage: background,
|
||||||
|
|
||||||
|
}).draw();
|
||||||
|
|
||||||
|
fs.writeFileSync("./images/" + rand + ".png", buffer);
|
||||||
|
const file = new AttachmentBuilder('./images/' + rand + ".png");
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
.setColor("#FF0000")
|
.setColor("#FF0000")
|
||||||
.setTitle("Your Generated QR Code")
|
.setTitle("Your Generated QR Code")
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setImage(`attachment://images/${fileName}.png`)
|
.setImage('attachment://images/' + rand + ".png")
|
||||||
|
|
||||||
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
try {
|
interaction.editReply({ embeds: [embed], files: [file] });
|
||||||
const message = await interaction.channel.send({ embeds: [embed], files: [file] });
|
})();
|
||||||
setTimeout(async () => {
|
|
||||||
// await message.delete();
|
|
||||||
console.log(message)
|
|
||||||
await fs.unlink(`./images/${fileName}.png`);
|
|
||||||
}, 10000);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,35 +1,63 @@
|
|||||||
const client = require("../index");
|
const client = require("../index");
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
const fs = require("fs").promises;
|
const { glob } = require("glob");
|
||||||
|
const { promisify } = require("util");
|
||||||
|
const globPromise = promisify(glob);
|
||||||
|
|
||||||
client.on("interactionCreate", async (interaction) => {
|
client.on("interactionCreate", async (interaction) => {
|
||||||
|
|
||||||
// Slash Commands
|
// Slash Commands
|
||||||
const slashCommands = await fs.readdir(`${process.cwd()}/commands/*/*.js`);
|
const slashCommands = await globPromise(`${process.cwd()}/commands/*/*.js`);
|
||||||
const arrayOfSlashCommands = slashCommands.map((filename) => {
|
const arrayOfSlashCommands = [];
|
||||||
const file = require(`${process.cwd()}/commands/${filename}`);
|
slashCommands.map((value) => {
|
||||||
|
const file = require(value);
|
||||||
|
const splitted = value.split("/");
|
||||||
|
const directory = splitted[splitted.length - 2];
|
||||||
|
|
||||||
if (!file?.name) return;
|
if (!file?.name) return;
|
||||||
|
|
||||||
|
const properties = { directory, ...file };
|
||||||
|
client.slashCommands.set(file.name, properties);
|
||||||
|
|
||||||
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
|
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
|
||||||
return file;
|
arrayOfSlashCommands.push(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Slash Command Handling
|
// Slash Command Handling
|
||||||
if (interaction.isChatInputCommand()) {
|
if (interaction.isChatInputCommand()) {
|
||||||
const commandData = arrayOfSlashCommands.find(
|
|
||||||
(command) => command.name === interaction.commandName
|
|
||||||
);
|
|
||||||
if (!commandData) return;
|
|
||||||
|
|
||||||
const cmd = client.slashCommands.get(interaction.commandName);
|
let commandData = []
|
||||||
if (!cmd) return interaction.followUp({ content: "An error has occurred " });
|
await arrayOfSlashCommands.forEach(command => {
|
||||||
|
console.log(command.name)
|
||||||
const args = interaction.options.data.map((option) => {
|
if (command.name == interaction.commandName) {
|
||||||
if (option.type === "SUB_COMMAND") {
|
commandData.push(command)
|
||||||
if (option.name) return option.name;
|
|
||||||
return option.options?.map((x) => x.value).filter((x) => x);
|
|
||||||
}
|
}
|
||||||
return option.value;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let dataToProcess = JSON.stringify(commandData[0])
|
||||||
|
let parsedData = JSON.parse(dataToProcess)
|
||||||
|
|
||||||
|
if (parsedData.private == true) {
|
||||||
|
await interaction.deferReply({ ephemeral: true }).catch(() => { });
|
||||||
|
|
||||||
|
} else {
|
||||||
|
await interaction.deferReply({ ephemeral: false }).catch(() => { });
|
||||||
|
}
|
||||||
|
|
||||||
|
const cmd = client.slashCommands.get(interaction.commandName);
|
||||||
|
if (!cmd)
|
||||||
|
return interaction.followUp({ content: "An error has occurred " });
|
||||||
|
|
||||||
|
const args = [];
|
||||||
|
|
||||||
|
for (let option of interaction.options.data) {
|
||||||
|
if (option.type === "SUB_COMMAND") {
|
||||||
|
if (option.name) args.push(option.name);
|
||||||
|
option.options?.forEach((x) => {
|
||||||
|
if (x.value) args.push(x.value);
|
||||||
|
});
|
||||||
|
} else if (option.value) args.push(option.value);
|
||||||
|
}
|
||||||
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
|
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
|
||||||
|
|
||||||
cmd.run(client, interaction, args);
|
cmd.run(client, interaction, args);
|
||||||
@ -41,4 +69,5 @@ client.on("interactionCreate", async (interaction) => {
|
|||||||
const command = client.slashCommands.get(interaction.commandName);
|
const command = client.slashCommands.get(interaction.commandName);
|
||||||
if (command) command.run(client, interaction);
|
if (command) command.run(client, interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,60 +1,34 @@
|
|||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
const fs = require("fs").promises;
|
const { glob } = require("glob");
|
||||||
|
const { promisify } = require("util");
|
||||||
|
const globPromise = promisify(glob);
|
||||||
|
|
||||||
module.exports = async (client) => {
|
module.exports = async (client) => {
|
||||||
// Slash Commands
|
// Slash Commands
|
||||||
const slashCommands = await fs.readdir(`${process.cwd()}/commands/*/*.js`);
|
const slashCommands = await globPromise(`${process.cwd()}/commands/*/*.js`);
|
||||||
const arrayOfSlashCommands = slashCommands.map((filename) => {
|
const arrayOfSlashCommands = [];
|
||||||
const file = require(`${process.cwd()}/commands/${filename}`);
|
slashCommands.map((value) => {
|
||||||
|
const file = require(value);
|
||||||
|
const splitted = value.split("/");
|
||||||
|
const directory = splitted[splitted.length - 2];
|
||||||
|
|
||||||
if (!file?.name) return;
|
if (!file?.name) return;
|
||||||
|
|
||||||
|
const properties = { directory, ...file };
|
||||||
|
client.slashCommands.set(file.name, properties);
|
||||||
|
|
||||||
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
|
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
|
||||||
return file;
|
arrayOfSlashCommands.push(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
const eventFiles = await fs.readdir(`${process.cwd()}/events/*.js`);
|
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
|
||||||
eventFiles.forEach((filename) => require(`${process.cwd()}/events/${filename}`));
|
eventFiles.map((value) => require(value));
|
||||||
|
|
||||||
// Slash Commands Register
|
// Slash Commands Register
|
||||||
client.on("ready", async () => {
|
client.on("ready", async () => {
|
||||||
// Register for all the guilds the bot is in
|
// Register for all the guilds the bot is in
|
||||||
await client.application.commands.set(arrayOfSlashCommands);
|
await client.application.commands.set(arrayOfSlashCommands);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("interactionCreate", async (interaction) => {
|
};
|
||||||
// Slash Command Handling
|
|
||||||
if (interaction.isChatInputCommand()) {
|
|
||||||
let commandData = arrayOfSlashCommands.find((command) => command.name === interaction.commandName);
|
|
||||||
if (!commandData) return interaction.followUp({ content: "An error has occurred " });
|
|
||||||
const cmd = client.slashCommands.get(interaction.commandName);
|
|
||||||
if (!cmd) return interaction.followUp({ content: "An error has occurred " });
|
|
||||||
|
|
||||||
const args = [];
|
|
||||||
for (let option of interaction.options.data) {
|
|
||||||
if (option.type === "SUB_COMMAND") {
|
|
||||||
if (option.name) args.push(option.name);
|
|
||||||
option.options?.forEach((x) => {
|
|
||||||
if (x.value) args.push(x.value);
|
|
||||||
});
|
|
||||||
} else if (option.value) args.push(option.value);
|
|
||||||
}
|
|
||||||
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
|
|
||||||
|
|
||||||
if (commandData.private) {
|
|
||||||
await interaction.deferReply({ ephemeral: true }).catch(() => { });
|
|
||||||
} else {
|
|
||||||
await interaction.deferReply({ ephemeral: false }).catch(() => { });
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.run(client, interaction, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Context Menu Handling
|
|
||||||
if (interaction.isContextMenuCommand()) {
|
|
||||||
await interaction.deferReply({ ephemeral: false });
|
|
||||||
const command = client.slashCommands.get(interaction.commandName);
|
|
||||||
if (command) command.run(client, interaction);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user