Added gamexplain and yoda, replaced many unneeded packages
This commit is contained in:
parent
346c40d492
commit
7d1ca165b7
17 changed files with 301 additions and 430 deletions
25
commands/gamexplain.js
Normal file
25
commands/gamexplain.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const fetch = require("node-fetch");
|
||||
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 GameXplain thumbnail meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/gamexplain.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
const command = gm(template).out("-background").out("white").out("-gravity").out("Center").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("1181x571!").out(")").out("-geometry").out("+0+40").out("-composite").out(")").out("+swap").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
return message.channel.createMessage("", {
|
||||
file: resultBuffer,
|
||||
name: "gamexplain.png"
|
||||
});
|
||||
};
|
||||
|
||||
exports.aliases = ["gx"];
|
|
@ -3,7 +3,6 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const tempy = require("tempy");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -12,8 +11,8 @@ exports.run = async (message) => {
|
|||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = tempy.file({ extension: image.type });
|
||||
const data2 = tempy.file({ extension: image.type });
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("West").crop("50%", 0).strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flop().strip().write(data, async (error) => {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const tempy = require("tempy");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -12,8 +11,8 @@ exports.run = async (message) => {
|
|||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = tempy.file({ extension: image.type });
|
||||
const data2 = tempy.file({ extension: image.type });
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("South").crop(0, "50%").strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flip().strip().write(data, async (error) => {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
const GoogleImages = require("google-images");
|
||||
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) => {
|
||||
if (!message.channel.guild.members.get(client.user.id).permission.has("addReactions") && !message.channel.permissionsOf(client.user.id).has("addReactions")) return `${message.author.mention}, I don't have the \`Add Reactions\` permission!`;
|
||||
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 imageSearch = new GoogleImages(config.cseID, config.googleKey);
|
||||
const images = await imageSearch.search(args.join(" "), { safe: "high" });
|
||||
for (const [i, value] of images.entries()) {
|
||||
const images = await search.cse.list({ searchType: "image", safe: "active", cx: config.cseID, q: args.join(" "), auth: config.googleKey });
|
||||
for (const [i, value] of images.data.items.entries()) {
|
||||
embeds.push({
|
||||
"embed": {
|
||||
"title": "Search Results",
|
||||
|
@ -19,7 +19,7 @@ exports.run = async (message, args) => {
|
|||
"text": `Page ${i + 1} of ${images.length}`
|
||||
},
|
||||
"image": {
|
||||
"url": value.url
|
||||
"url": value.link
|
||||
},
|
||||
"author": {
|
||||
"name": message.author.username,
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
const urlCheck = require("../utils/urlcheck.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
message.channel.sendTyping();
|
||||
if (args.length === 0 || !urlCheck(args[0])) return `${message.author.mention}, you need to provide a short URL to lengthen!`;
|
||||
if (urlCheck(args[0])) {
|
||||
const url = await require("url-unshort")().expand(args[0]);
|
||||
return url;
|
||||
//const url = await require("url-unshort")().expand(args[0]);
|
||||
const url = await fetch(args[0], { redirect: "manual" });
|
||||
return url.headers.get("location") || args[0];
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/scott.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = require("tempy").file({ extension: image.type });
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
const command = gm(template).out("-gravity").out("Center").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("415x234!").out("+distort").out("Perspective").out("0,0 129,187 415,0 517,182 415,234 517,465 0,234 132,418").out("-geometry").out("-110+83").out(")").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
|
|
|
@ -2,14 +2,13 @@ const gm = require("gm").subClass({
|
|||
imageMagick: true
|
||||
});
|
||||
const gmToBuffer = require("../utils/gmbuffer.js");
|
||||
const tempy = require("tempy");
|
||||
const wrap = require("../utils/wrap.js");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide an image to make a Sonic meme!`;
|
||||
message.channel.sendTyping();
|
||||
const template = "./assets/images/sonic.jpg";
|
||||
const file = tempy.file({ extension: "png" });
|
||||
const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
|
||||
const cleanedMessage = args.join(" ").replace(/&/g, "\\&").replace(/>/g, "\\>").replace(/</g, "\\<");
|
||||
gm(474, 332).out("+size").gravity("Center").out("-pointsize", 40).out("-font", "Bitstream Vera Sans").out(`pango:${wrap(cleanedMessage, {width: 15, indent: ""})}`).negative().out("-fuzz", "30%").transparent("black").write(file, async (error) => {
|
||||
if (error) console.error;
|
||||
|
|
|
@ -12,9 +12,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/trump.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = require("tempy").file({
|
||||
extension: image.type
|
||||
});
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
const command = gm(template).out("-background").out("none").out("-gravity").out("South").out("(").out("-clone").out("0").out("(").out(path).out("-virtual-pixel").out("transparent").out("-resize").out("365x179!").out("+distort").out("Perspective").out("0,0 207,268 365,0 548,271 365,179 558,450 0,179 193,450").out(")").out("-geometry").out("-25-1").out("-composite").out(")").out("+swap").out("-composite");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const tempy = require("tempy");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -12,12 +11,8 @@ exports.run = async (message) => {
|
|||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = tempy.file({
|
||||
extension: image.type
|
||||
});
|
||||
const data2 = tempy.file({
|
||||
extension: image.type
|
||||
});
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("East").crop("50%", 0).strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flop().strip().write(data, async (error) => {
|
||||
|
|
|
@ -12,9 +12,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/whodidthis.png";
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const path = require("tempy").file({
|
||||
extension: image.type
|
||||
});
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, imageBuffer);
|
||||
const command = gm(template).composite(path).gravity("Center").geometry("374x374+0+0");
|
||||
const resultBuffer = await gmToBuffer(command);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
const gm = require("gm").subClass({
|
||||
imageMagick: true
|
||||
});
|
||||
const tempy = require("tempy");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message) => {
|
||||
|
@ -12,12 +11,8 @@ exports.run = async (message) => {
|
|||
message.channel.sendTyping();
|
||||
const imageData = await fetch(image.url);
|
||||
const imageBuffer = await imageData.buffer();
|
||||
const data = tempy.file({
|
||||
extension: image.type
|
||||
});
|
||||
const data2 = tempy.file({
|
||||
extension: image.type
|
||||
});
|
||||
const data = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
const data2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
gm(imageBuffer).gravity("North").crop(0, "50%").strip().write(data2, (error) => {
|
||||
if (error) console.error;
|
||||
gm(data2).flip().strip().write(data, async (error) => {
|
||||
|
|
10
commands/yoda.js
Normal file
10
commands/yoda.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide some text to translate to Yodish!`;
|
||||
const request = await fetch(`https://yoda-api.appspot.com/api/v1/yodish?text=${args.join("%20")}`);
|
||||
const json = await request.json();
|
||||
return json.yodish;
|
||||
};
|
||||
|
||||
exports.aliases = ["yodish"];
|
|
@ -1,16 +1,21 @@
|
|||
const YouTube = require("simple-youtube-api");
|
||||
const { google } = require("googleapis");
|
||||
const config = require("../config.json");
|
||||
const youtube = new YouTube(config.googleKey);
|
||||
const youtube = google.youtube({
|
||||
version: "v3",
|
||||
auth: config.googleKey,
|
||||
});
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide something to search for!`;
|
||||
message.channel.sendTyping();
|
||||
const result = await youtube.search(args.join(" "), 1);
|
||||
if (result[0].type === "channel") {
|
||||
return `<:youtube:637020823005167626> **${result[0].raw.snippet.title.replace("*", "\\*")}**\nhttps://youtube.com/channel/${result[0].id}`;
|
||||
} else if (result[0].type === "playlist") {
|
||||
return `<:youtube:637020823005167626> **${result[0].title.replace("*", "\\*")}**\nCreated by **${result[0].channel.title.replace("*", "\\*")}**\nhttps://youtube.com/playlist?list=${result[0].id}`;
|
||||
const result = await youtube.search.list({ q: args.join(" "), part: "snippet" });
|
||||
if (result.data.items[0].id.kind === "youtube#channel") {
|
||||
return `<:youtube:637020823005167626> **${result.data.items[0].snippet.title.replace("*", "\\*")}**\nhttps://youtube.com/channel/${result.data.items[0].id.channelId}`;
|
||||
} else if (result.data.items[0].id.kind === "youtube#playlist") {
|
||||
return `<:youtube:637020823005167626> **${result.data.items[0].snippet.title.replace("*", "\\*")}**\nCreated by **${result.data.items[0].snippet.channelTitle.replace("*", "\\*")}**\nhttps://youtube.com/playlist?list=${result.data.items[0].id.playlistId}`;
|
||||
} else {
|
||||
return `<:youtube:637020823005167626> **${result[0].title.replace("*", "\\*")}**\nUploaded by **${result[0].channel.title.replace("*", "\\*")}** on **${result[0].publishedAt.toISOString().split("T")[0]}**\nhttps://youtube.com/watch?v=${result[0].id}`;
|
||||
return `<:youtube:637020823005167626> **${result.data.items[0].snippet.title.replace("*", "\\*")}**\nUploaded by **${result.data.items[0].snippet.channelTitle.replace("*", "\\*")}** on **${result.data.items[0].snippet.publishedAt.split("T")[0]}**\nhttps://youtube.com/watch?v=${result.data.items[0].id.videoId}`;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.aliases = ["yt", "video", "ytsearch"];
|
Loading…
Add table
Add a link
Reference in a new issue