thaldrin/DiscordModules/Roleplay/nhold.js
2019-11-20 18:05:10 +01:00

65 lines
1.7 KiB
JavaScript

const Command = require('../../src/structures/Command');
const yiff = require('yiff');
const { MessageEmbed } = require('discord.js');
module.exports = class nHold extends Command {
constructor() {
super({
name: 'nhold',
description: 'Hold a user',
aliases: [],
module: 'Roleplay',
cooldown: 2,
guildOnly: true,
developerOnly: false,
nsfw: true
});
}
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 hold me! Hold someone else!");
if (ctx.msg.mentions.members.first().id === ctx.author.id)
return ctx.send(`Don't you want to hold someone other than yourself?`);
const Server = await ctx.db.servers.get(ctx.guild.id);
let Line;
let Settings;
if (Server === null) {
Settings = ctx.utils.db.defaults.server;
} else {
Settings = Server;
}
if (Settings.rp_text) {
const LineFromUtils = ctx.utils.int.hold[parseInt(Math.random() * ctx.utils.int.hold.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;
}
let req;
let Message;
await yiff.sheri.nsfw.hold().then((E) => (req = E));
if (Settings.embeds) {
Message = new MessageEmbed()
.setColor(ctx.config.color)
.setImage(req.url)
.setFooter(`${ctx.client.user.username} - Provided by sheri.bot`, ctx.client.user.avatarURL());
if (Line) {
Message.setDescription(Line);
}
} else {
if (Line) {
Message = `${Line}\n${req}`;
} else {
Message = `${req}`;
}
}
ctx.send(Message);
}
};