Commit ea4094bf authored by recette lemonweed's avatar recette lemonweed 🇮🇸

added ext filtering to image commands

parent ddd8360f
......@@ -3,10 +3,10 @@ module.exports = {
triggers: ["ika"],
description: "Posts a cute image of Ika.",
category: "image",
arguments: {},
arguments: Utility.imageCommandArguments,
func: func
};
function func(message, args){
Utility.imageCommand(message, "ika");
Utility.imageCommand(message, args, "ika");
}
......@@ -163,9 +163,22 @@ module.exports.MessageControls = class MessageControls extends require("events")
}
};
module.exports.imageCommand = function(message, folder){
let n = Math.floor(Math.random() * Images[folder].length),
file = Images[folder][n],
module.exports.imageCommandArguments = {
flags: {
extension: [false, "ext", "e"]
}
};
module.exports.imageCommand = function(message, args, folder){
let imgs = Images[folder];
if(args.ext){
imgs = imgs.filter(i => i.endsWith("."+args.ext));
if(imgs.length === 0)
return message.reply("No files with that ext.");
}
let n = Math.floor(Math.random() * imgs.length),
file = imgs[n],
ext = file.split(".").pop(),
name = folder+"-"+(n+1)+"."+ext;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment