Added leak and exec, moved from a config.json file to a .env file, other changes

This commit is contained in:
TheEssem 2019-11-12 18:09:06 -06:00
parent ef071a39d4
commit d661b58271
24 changed files with 216 additions and 58 deletions

View file

@ -1,11 +1,10 @@
const fetch = require("node-fetch");
const config = require("../config.json");
exports.run = async (message) => {
message.channel.sendTyping();
const data = await fetch("https://api.thecatapi.com/v1/images/search?format=json", {
headers: {
"x-api-key": config.catToken
"x-api-key": process.env.CAT
}
});
const json = await data.json();

18
commands/exec.js Normal file
View file

@ -0,0 +1,18 @@
const { clean } = require("../utils/misc.js");
const util = require("util");
const exec = util.promisify(require("child_process").exec);
exports.run = async (message, args) => {
if (message.author.id !== "198198681982205953") return `${message.author.mention}, only the bot owner can use exec!`;
const code = args.join(" ");
try {
const execed = await exec(code);
if (execed.stderr) return `\`ERROR\` \`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``;
const cleaned = await clean(execed.stdout);
return `\`\`\`bash\n${cleaned}\n\`\`\``;
} catch (err) {
return `\`ERROR\` \`\`\`xl\n${await clean(err)}\n\`\`\``;
}
};
exports.aliases = ["runcmd"];

View file

@ -1,7 +1,6 @@
const { google } = require("googleapis");
const client = require("../utils/client.js");
const paginator = require("../utils/pagination/pagination");
const config = require("../config.json");
const search = google.customsearch("v1");
exports.run = async (message, args) => {
@ -9,7 +8,7 @@ exports.run = async (message, args) => {
if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`;
if (args.length === 0) return `${message.author.mention}, you need to provide something to search for!`;
const embeds = [];
const images = await search.cse.list({ searchType: "image", safe: "active", cx: config.cseID, q: args.join(" "), auth: config.googleKey });
const images = await search.cse.list({ searchType: "image", safe: "active", cx: process.env.CSE, q: args.join(" "), auth: process.env.GOOGLE });
for (const [i, value] of images.data.items.entries()) {
embeds.push({
"embed": {

View file

@ -1,8 +1,7 @@
const client = require("../utils/client.js");
const config = require("../config.json");
exports.run = async (message) => {
const dev = client.users.get(config.botOwner);
const dev = client.users.get(process.env.OWNER);
const artist = client.users.get("401980971517214723");
const infoEmbed = {
"embed": {

22
commands/leak.js Normal file
View file

@ -0,0 +1,22 @@
const gm = require("gm").subClass({
imageMagick: true
});
const gmToBuffer = require("../utils/gmbuffer.js");
const fs = require("fs");
exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to make a Super Smash Bros. leak meme!`;
message.channel.sendTyping();
const template = "./assets/images/leak.png";
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
require("util").promisify(fs.writeFile)(path, image.data);
const command = gm(template).out("-background").out("white").out("-gravity").out("Center").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("white").out("-resize").out("640x360!").rotate("white", 15).out(")").out("-geometry").out("+450-200").out("-composite").out(")").out("+swap").out("-composite").out("-alpha").out("remove").out("-alpha").out("off");
const resultBuffer = await gmToBuffer(command, "png");
return message.channel.createMessage("", {
file: resultBuffer,
name: "leak.png"
});
};
exports.aliases = ["smash", "laxchris", "ssbu", "smashleak"];

View file

@ -1,7 +1,7 @@
const handler = require("../utils/handler.js");
exports.run = async (message, args) => {
if (message.author.id !== require("../config.json").botOwner) return `${message.author.mention}, only the bot owner can reload commands!`;
if (message.author.id !== process.env.OWNER) return `${message.author.mention}, only the bot owner can reload commands!`;
if (args.length === 0) return `${message.author.mention}, you need to provide a command to reload!`;
try {
await handler.unload(args[0]);

View file

@ -2,7 +2,7 @@ const handler = require("../utils/handler.js");
const collections = require("../utils/collections.js");
exports.run = async (message) => {
if (message.author.id !== require("../config.json").botOwner) return `${message.author.mention}, only the bot owner can restart me!`;
if (message.author.id !== process.env.OWNER) return `${message.author.mention}, only the bot owner can restart me!`;
await message.channel.createMessage(`${message.author.mention}, esmBot is restarting.`);
collections.commands.forEach(async (command) => {
await handler.unload(command);

View file

@ -1,5 +1,4 @@
const database = require("../utils/database.js");
const config = require("../config.json");
const client = require("../utils/client.js");
const paginator = require("../utils/pagination/pagination.js");
const { random } = require("../utils/misc.js");
@ -19,14 +18,14 @@ exports.run = async (message, args) => {
case "remove":
if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to delete!`;
if (!tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
if (tags.get(args[1].toLowerCase()).author !== message.author.id && tags.get(args[1].toLowerCase()).author !== config.botOwner) return `${message.author.mention}, you don't own this tag!`;
if (tags.get(args[1].toLowerCase()).author !== message.author.id && tags.get(args[1].toLowerCase()).author !== process.env.OWNER) return `${message.author.mention}, you don't own this tag!`;
tags.set(args[1].toLowerCase(), undefined);
await guild.save();
return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been deleted!`;
case "edit":
if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to edit!`;
if (!tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
if (tags.get(args[1].toLowerCase()).author !== message.author.id && tags.get(args[1].toLowerCase()).author !== config.botOwner) return `${message.author.mention}, you don't own this tag!`;
if (tags.get(args[1].toLowerCase()).author !== message.author.id && tags.get(args[1].toLowerCase()).author !== process.env.OWNER) return `${message.author.mention}, you don't own this tag!`;
await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guild);
return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been edited!`;
case "list":

View file

@ -1,11 +1,10 @@
const fetch = require("node-fetch");
const config = require("../config.json");
exports.run = async (message) => {
message.channel.sendTyping();
const request = await fetch("https://hargrimm-wikihow-v1.p.mashape.com/images?count=1", {
headers: {
"X-Mashape-Key": config.mashapeKey,
"X-Mashape-Key": process.env.MASHAPE,
"Accept": "application/json"
}
});

View file

@ -1,8 +1,7 @@
const { google } = require("googleapis");
const config = require("../config.json");
const youtube = google.youtube({
version: "v3",
auth: config.googleKey,
auth: process.env.GOOGLE,
});
exports.run = async (message, args) => {