thaldrin/DiscordModules/Images/e621.js

59 lines
1.5 KiB
JavaScript
Executable File

const Command = require("../../src/structures/Command");
const yiff = require("yiff");
const { MessageEmbed } = require("discord.js");
let Icon =
"https://cdn6.aptoide.com/imgs/0/7/f/07f23fe390d6d20f47839932ea23c678_icon.png?w=240";
module.exports = class E621 extends Command {
constructor() {
super({
name: "e621",
description: "Get Images from e621",
aliases: ["e6"],
module: "Images",
cooldown: 5,
guildOnly: false,
developerOnly: false
});
}
async command(ctx) {
let Embed = new MessageEmbed().setColor("RED");
if (!ctx.channel.nsfw) {
Embed.setTitle("NSFW").setDescription(
`This channel is not marked as NSFW, please mark it as such and rerun this command.`
);
return ctx.send(Embed);
}
if (ctx.args < 1) {
Embed.setTitle("Search Terms").setDescription(
"I need more tags than that to search for an Image."
);
return ctx.send(Embed);
}
const Server = await ctx.db.servers.get(ctx.guild.id);
let Settings;
if (Server === null) {
Settings = ctx.utils.db.defaults.server;
} else {
Settings = Server;
}
let message = await ctx.send(`Searching...`);
let req;
let Message;
await yiff.e621.CubFilter(ctx.args.join(" ")).then(E => (req = E));
if (Settings.embeds) {
Message = new MessageEmbed().setImage(req.image);
message.delete();
} else {
Message = `${req.image}`;
message.delete();
}
ctx.send(Message);
}
};