diff --git a/assets/images/trump.png b/assets/images/trump.png new file mode 100644 index 0000000..119d7dc Binary files /dev/null and b/assets/images/trump.png differ diff --git a/commands/tile.js b/commands/tile.js new file mode 100644 index 0000000..d96849c --- /dev/null +++ b/commands/tile.js @@ -0,0 +1,24 @@ +const gm = require("gm").subClass({ + imageMagick: true +}); +const gmToBuffer = require("../utils/gmbuffer.js"); +const fetch = require("node-fetch"); + +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 tile!`; + message.channel.sendTyping(); + const imageData = await fetch(image.url); + const imageBuffer = await imageData.buffer(); + gm(imageBuffer).command("montage").out("-duplicate").out(24).tile("5x5").geometry("+0+0").stream(async (error, output) => { + if (error) console.error; + const data = gm(output).resize("800x800>"); + const resultBuffer = await gmToBuffer(data); + return message.channel.createMessage("", { + file: resultBuffer, + name: `tile.${image.type}` + }); + }); +}; + +exports.aliases = ["wall2"]; diff --git a/commands/trump.js b/commands/trump.js new file mode 100644 index 0000000..ed44688 --- /dev/null +++ b/commands/trump.js @@ -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 Trump meme!`; + message.channel.sendTyping(); + 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 + }); + 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); + return message.channel.createMessage("", { + file: resultBuffer, + name: "trump.png" + }); +}; \ No newline at end of file diff --git a/commands/userinfo.js b/commands/userinfo.js new file mode 100644 index 0000000..c4f2f3b --- /dev/null +++ b/commands/userinfo.js @@ -0,0 +1,49 @@ +const client = require("../utils/client.js"); + +exports.run = async (message, args) => { + const getUser = message.mentions.length >= 1 ? message.mentions[0] : (args.length !== 0 ? client.users.get(args[0]) : message.author); + const user = getUser !== undefined ? getUser : message.author; + const member = message.channel.guild.members.get(user.id); + const infoEmbed = { + "embed": { + "title": `${user.username}#${user.discriminator}`, + "thumbnail": { + "url": user.avatarURL + }, + "color": 16711680, + "fields": [ + { + "name": "đŸ”ĸ **ID:**", + "value": user.id + }, + { + "name": "📛 **Nickname:**", + "value": member.nick ? member.nick : "None" + }, + { + "name": "🤖 **Bot:**", + "value": user.bot ? "Yes" : "No" + }, + { + "name": "🗓ī¸ **Joined Discord on:**", + "value": new Date(user.createdAt).toString() + }, + { + "name": "đŸ’Ŧ **Joined this server on:**", + "value": new Date(member.joinedAt).toString() + }, + { + "name": "ℹī¸ **Status:**", + "value": member.status + }, + { + "name": "🎮 **Playing:**", + "value": member.activities ? member.activities[0].name : "Nothing" + } + ] + } + }; + return message.channel.createMessage(infoEmbed); +}; + +exports.aliases = ["user"]; \ No newline at end of file diff --git a/commands/waaw.js b/commands/waaw.js new file mode 100644 index 0000000..e775987 --- /dev/null +++ b/commands/waaw.js @@ -0,0 +1,37 @@ +// really don't like this file + +const gm = require("gm").subClass({ + imageMagick: true +}); +const tempy = require("tempy"); +const fetch = require("node-fetch"); + +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 mirror!`; + 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 + }); + gm(imageBuffer).gravity("East").crop("50%", 0).strip().write(data2, (error) => { + if (error) console.error; + gm(data2).flop().strip().write(data, async (error) => { + if (error) console.error; + gm(data).append(data2, true).toBuffer(image.type, (error, resultBuffer) => { + if (error) console.error; + return message.channel.createMessage("", { + file: resultBuffer, + name: `waaw.${image.type}` + }); + }); + }); + }); +}; + +exports.aliases = ["magik3", "mirror"]; + diff --git a/events/error.js b/events/error.js index 6747fb2..ab72b6a 100644 --- a/events/error.js +++ b/events/error.js @@ -2,6 +2,5 @@ const logger = require("../utils/logger.js"); // run when eris encounters an error module.exports = async (error, id) => { - logger.error(`An error event was sent by Eris in shard ${id}: \n${error.toString()}`); - logger.error(error.toString()); + logger.error(`An error event was sent by Eris in shard ${id}: \n${error.message}`); }; diff --git a/events/messageCreate.js b/events/messageCreate.js index 7203bc4..43f07f1 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -16,7 +16,8 @@ module.exports = async (message) => { const prefix = prefixMention.test(message.content) ? message.content.match(prefixMention)[0] : guildConf.prefix; // ignore other stuff - if (message.content.startsWith(prefix) === false && message.mentions.indexOf(client.user) <= -1 && message.channel.id !== "573553254575898626") return; + // && !message.attachments && message.attachments[0].filename !== "1561668913236-3.gif" + if (message.content.startsWith(prefix) === false && message.mentions.indexOf(client.user) <= -1 && message.channel.id !== "573553254575898626" && (!message.content.match(/https?:\/\/(media|cdn)\.discordapp\.(net|com)\/attachments\/596766080014221373\/606176845871972383\/1561668913236-3.gif/))) return; // funny stuff if (message.channel.id === "573553254575898626" && message.channel.guild.id === "433408970955423765") { @@ -32,6 +33,12 @@ module.exports = async (message) => { await client.createMessage(generalChannel.id, message.content); } } + const odyMessages = ["Nope!", "No jojo gif here", "sorry ody, this gif is illegal", "get owned"]; + // || (message.attachments && message.attachments[0].filename === "1561668913236-3.gif") + if (message.channel.guild.id === "322114245632327703" && (message.content.match(/https?:\/\/(media|cdn)\.discordapp\.(net|com)\/attachments\/596766080014221373\/606176845871972383\/1561668913236-3.gif/))) { + await message.delete("anti-jojo mechanism"); + await client.createMessage(message.channel.id, misc.random(odyMessages)); + } // separate commands and args const escapedPrefix = misc.regexEscape(prefix); diff --git a/utils/pagination/pagination.js b/utils/pagination/pagination.js index 9e1d017..6a8ebc5 100644 --- a/utils/pagination/pagination.js +++ b/utils/pagination/pagination.js @@ -3,6 +3,7 @@ const MessageCollector = require("./awaitmessages.js"); const client = require("../client.js"); const paginationEmbed = async (message, pages, timeout = 120000) => { + const manageMessages = message.channel.guild.members.get(client.user.id).permission.has("manageMessages") || message.channel.permissionsOf(client.user.id).has("manageMessages") ? true : false; let page = 0; pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; const currentPage = await message.channel.createMessage(pages[page]); @@ -11,36 +12,44 @@ const paginationEmbed = async (message, pages, timeout = 120000) => { await currentPage.addReaction(emoji); } const reactionCollector = new ReactionCollector(currentPage, (message, reaction, user) => emojiList.includes(reaction.name) && !client.users.get(user).bot, { time: timeout }); - reactionCollector.on("reaction", (msg, reaction) => { - //reaction.users.remove(msg.author); - //const reactionAuthor = currentPage.getReactions(); - switch (reaction.name) { - case "◀": - page = page > 0 ? --page : pages.length - 1; - pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; - currentPage.edit(pages[page]); - break; - case "đŸ”ĸ": - message.channel.createMessage(`${message.author.mention}, what page do you want to jump to?`).then(askMessage => { - const messageCollector = new MessageCollector(askMessage.channel, (response) => response.author.id === message.author.id && !isNaN(response.content) && Number(response.content) <= pages.length, { time: timeout, maxMatches: 1 }); - return messageCollector.on("message", response => { - askMessage.delete(); - page = Number(response.content) - 1; - pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; - currentPage.edit(pages[page]); + reactionCollector.on("reaction", (msg, reaction, userID) => { + if (userID === message.author.id) { + switch (reaction.name) { + case "◀": + page = page > 0 ? --page : pages.length - 1; + pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; + currentPage.edit(pages[page]); + if (manageMessages) msg.removeReaction("◀", userID); + break; + case "đŸ”ĸ": + message.channel.createMessage(`${message.author.mention}, what page do you want to jump to?`).then(askMessage => { + const messageCollector = new MessageCollector(askMessage.channel, (response) => response.author.id === message.author.id && !isNaN(response.content) && Number(response.content) <= pages.length, { + time: timeout, + maxMatches: 1 + }); + return messageCollector.on("message", response => { + askMessage.delete(); + page = Number(response.content) - 1; + pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; + currentPage.edit(pages[page]); + if (manageMessages) msg.removeReaction("đŸ”ĸ", userID); + }); + }).catch(error => { + if (error) console.error; }); - }).catch(error => { if (error) console.error; }); - break; - case "â–ļ": - page = page + 1 < pages.length ? ++page : 0; - pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; - currentPage.edit(pages[page]); - break; - case "🗑": - currentPage.delete(); - return; - default: - break; + break; + case "â–ļ": + page = page + 1 < pages.length ? ++page : 0; + pages[page].embed.footer.text = `Page ${page + 1} of ${pages.length}`; + currentPage.edit(pages[page]); + if (manageMessages) msg.removeReaction("â–ļ", userID); + break; + case "🗑": + currentPage.delete(); + return; + default: + break; + } } }); reactionCollector.on("end", () => currentPage.removeReactions()); diff --git a/utils/soundplayer.js b/utils/soundplayer.js index 59e45c5..93eb0d9 100644 --- a/utils/soundplayer.js +++ b/utils/soundplayer.js @@ -1,4 +1,6 @@ const client = require("./client.js"); +const fs = require("fs"); +const logger = require("./logger.js"); module.exports = async (sound, message) => { if (message.member.voiceState.channelID) { @@ -9,10 +11,10 @@ module.exports = async (sound, message) => { if (connection.playing) { connection.stopPlaying(); } - connection.play(require("fs").createReadStream(sound)); + connection.play(fs.createReadStream(sound)); connection.on("error", (error) => { voiceChannel.leave(); - require("./logger.js").error(error); + logger.error(error); }); connection.once("end", () => { voiceChannel.leave();