This commit is contained in:
codepupper 2019-11-11 18:08:27 +01:00
parent 30a1644d10
commit 314c1847ed
7 changed files with 52 additions and 34 deletions

View file

@ -1,4 +1,4 @@
const { Collection } = require('discord.js');
const { Collection, MessageEmbed } = require('discord.js');
const { table } = require('quick.db');
const Servers = new table('servers');
const Users = new table('users');
@ -58,8 +58,9 @@ module.exports = {
if (cmd.nsfw && !ctx.channel.nsfw)
return ctx.send('This channel is not marked as NSFW, please mark it as such and rerun this command.');
if (cmd.developerOnly && !client.config.developers.find((dev) => msg.author.id == dev.id)) return;
if (cmd.AuthorPermissions !== 'NONE' && !ctx.member.permissions.has(cmd.AuthorPermissions))
if (cmd.AuthorPermissions !== 'NONE' && !ctx.member.permissions.has(cmd.AuthorPermissions)) {
return ctx.send(`You need \`${cmd.AuthorPermissions}\` Permission(s) to run this Command`);
}
const now = Date.now();
const timestamps = client.cooldowns.get(cmd.name);
const cooldownAmount = (cmd.cooldown || 1) * 1000;
@ -68,14 +69,16 @@ module.exports = {
const expirationTime = timestamps.get(msg.author.id) + cooldownAmount;
if (now < expirationTime) {
let CooldownEmb = new MessageEmbed();
const timeLeft = (expirationTime - now) / 1000;
return ctx.send(
CooldownEmb.setTitle(`${cmd.name} is on cooldown`).setDescription(
`\`${cmd.name}\` has a cooldown of \`${cmd.cooldown} second${cmd.cooldown > 1
? 's'
: ''}\`, wait \`${`${Math.round(timeLeft)} second${Math.round(timeLeft) > 1
: ''}\`\n Wait \`${`${Math.round(timeLeft)} second${Math.round(timeLeft) > 1
? 's'
: ''}`.replace('0 second', 'just a second longer')}\` before trying to use it again.`
);
return ctx.send(CooldownEmb);
}
} else {
timestamps.set(msg.author.id, now);