-
Notifications
You must be signed in to change notification settings - Fork 44
/
paheal.js
55 lines (49 loc) · 2.09 KB
/
paheal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const { Command } = require('../../commando');
const Discord = require('discord.js');
const booru = require('booru');
const errors = require('../../assets/json/errors');
module.exports = class PahealCommand extends Command {
constructor(client) {
super(client, {
name: 'paheal',
aliases: ['ph'],
group: 'nsfw',
memberName: 'paheal',
guildOnly: true,
description: 'Searches for images on Paheal!',
details: 'This command can only be used in NSFW channels!',
examples: ['~paheal <search>'],
throttling: {
usages: 1,
duration: 3
}
});
}
run(message) {
var errMessage = errors[Math.round(Math.random() * (errors.length - 1))];
if (!message.channel.nsfw) {
message.react('💢');
return message.channel.send(errMessage);
}
if (message.content.toUpperCase().includes('LOLI') || message.content.toUpperCase().includes('GORE')) return message.channel.send('That kind of stuff is not allowed! Not even in NSFW channels!');
var query = message.content.split(/\s+/g).slice(1).join(" ");
booru.search('paheal', [query], { limit: 1, random: true })
.then(booru.commonfy)
.then(images => {
for (let image of images) {
const embed = new Discord.MessageEmbed()
.setAuthor(`Paheal ${query}`, 'https://b.catgirlsare.sexy/NrAI.png')
.setDescription(`[Image URL](${image.common.file_url})`)
.setImage(image.common.file_url)
.setColor('#E89F3E');
return message.channel.send({ embed });
}
}).catch(err => {
if (err.name === 'booruError') {
return message.channel.send(`No results found for **${query}**!`);
} else {
return message.channel.send(`No results found for **${query}**!`);
}
})
}
}