|
@@ -235,7 +235,37 @@ const onDirectMention = (msg, content, actionsDone) => {
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
+function processLastImage(msg, processor) {
|
|
|
+ let lastImagedMessage = msg.channel.messages.filter(m => !m.author.bot && m.attachments.find(v => util.isValidImage(v.filename) !== undefined)).last();
|
|
|
+
|
|
|
+ if(!lastImagedMessage) {
|
|
|
+ msg.channel.send(`${msg.author.toString()} Sorry, I couldn't find any recent messages with images.`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let image = lastImagedMessage.attachments.find(v => util.isValidImage(v.filename));
|
|
|
+
|
|
|
+ processFaceSwap(
|
|
|
+ msg,
|
|
|
+ image.url,
|
|
|
+ processor,
|
|
|
+ `${msg.author.toString()} Nice image! I don't see anything interesting, though.`,
|
|
|
+ `${msg.author.toString()} ${client.emojis.get("505076258753740810").toString()}`
|
|
|
+ ).catch(err => console.log(`Failed to run faceapp because ${err}`));
|
|
|
+}
|
|
|
+
|
|
|
+const commands = [
|
|
|
+{
|
|
|
+ pattern: "caption last image",
|
|
|
+ action: msg => processLastImage(msg, captionFace)
|
|
|
+},
|
|
|
+{
|
|
|
+ pattern: "look at last image",
|
|
|
+ action: msg => processLastImage(msg, morphFaces)
|
|
|
+}];
|
|
|
+
|
|
|
module.exports = {
|
|
|
onMessage: onMessage,
|
|
|
- onDirectMention: onDirectMention
|
|
|
+ onDirectMention: onDirectMention,
|
|
|
+ commands: commands
|
|
|
};
|