thaldrin/DiscordModules/Roleplay/hug.js

66 lines
1.7 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');
module.exports = class Hug extends Command {
constructor() {
super({
name: 'hug',
description: 'Hug a user',
aliases: [],
module: 'Roleplay',
cooldown: 2,
guildOnly: true,
developerOnly: false,
nsfw: false
});
}
async command(ctx) {
if (ctx.msg.mentions.members.size === 0) return ctx.send('please mention a user ;w;');
if (ctx.msg.mentions.members.first().id === ctx.client.user.id)
return ctx.send("Don't hug me! Hug someone else!");
if (ctx.msg.mentions.members.first().id === ctx.author.id)
return ctx.send(`Don't you want to hug someone other than yourself?`);
const Server = await ctx.db.servers.get(ctx.guild.id);
2019-11-11 17:08:27 +00:00
let Line;
2019-11-13 21:12:14 +00:00
let Settings;
2019-11-11 17:08:27 +00:00
if (Server === null) {
2019-11-13 21:12:14 +00:00
Settings = ctx.utils.db.defaults.server;
} else {
Settings = Server;
}
if (Settings.rp_text) {
2019-11-11 17:08:27 +00:00
const LineFromUtils = ctx.utils.int.hug[parseInt(Math.random() * ctx.utils.int.hug.length)];
Line = LineFromUtils.replace(/0/g, ctx.utils.format.bold(ctx.author.username)).replace(
/1/g,
ctx.utils.format.bold(ctx.msg.mentions.members.first().user.username)
);
} else {
Line = undefined;
}
2019-11-10 08:42:09 +00:00
let req;
let Message;
await yiff.furrybot.sfw.hug().then((E) => (req = E));
if (Settings.embeds) {
Message = new MessageEmbed()
.setColor(ctx.config.color)
.setImage(req)
.setFooter(`${ctx.client.user.username} - Provided by furry.bot`, ctx.client.user.avatarURL());
2019-11-11 17:08:27 +00:00
if (Line) {
Message.setDescription(Line);
}
2019-11-10 08:42:09 +00:00
} else {
2019-11-11 17:08:27 +00:00
if (Line) {
Message = `${Line}\n${req}`;
} else {
Message = `${req}`;
}
2019-11-10 08:42:09 +00:00
}
ctx.send(Message);
}
};