thaldrin/DiscordModules/Images/e621.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-11-10 08:42:09 +00:00
const Command = require('../../src/structures/Command');
const yiff = require('yiff');
const { MessageEmbed } = require('discord.js');
let Icon = 'https://werewoof.tech/e621.png';
2019-10-14 11:19:41 +00:00
module.exports = class E621 extends Command {
2019-11-10 08:42:09 +00:00
constructor() {
super({
name: 'e621',
description: 'Get Images from e621',
aliases: [ 'e6' ],
module: 'Images',
cooldown: 5,
guildOnly: false,
developerOnly: false,
nsfw: true
});
}
async command(ctx) {
let Embed = new MessageEmbed().setColor('RED');
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 req;
let Message;
await yiff.e621.CubFilter(ctx.args.join(' ')).then((E) => (req = E));
if (Settings.embeds) {
Message = new MessageEmbed()
.setImage(req.image)
.setColor(ctx.config.color)
.setAuthor('e621.net', Icon, `https://e621.net/post/show/${req.postID}`)
.setFooter(`${ctx.client.user.username} - e621.net`, ctx.client.user.avatarURL());
} else {
Message = `<https://e621.net/post/show/${req.postID}>\n${req.image}`;
}
ctx.send(Message);
}
2019-10-14 11:19:41 +00:00
};