/* DisShop Copyrights */ // Main Requirements \\ const { MessageEmbed } = require('discord.js'); const { Secrets, Channels, Guilds, Roles, Permission, Users } = require('../../config'); // Important Values \\ const commandInformation = { CommandName: 'revive', Alias: [], ReqPermissions: [Permission.ADMIN], ReqRoles: [Roles.MAIN_DEVT, Roles.MAIN_TESTT], ReqUsers: [], }; // Optional Requirements \\ const { QuickDB } = require('quick.db'); const db = new QuickDB(); const ms = require('ms'); const { create } = require('discord-timestamps'); const anyRequiredRoles = commandInformation.ReqRoles.length > 0; const anyRequiredPermissions = commandInformation.ReqPermissions.length > 0; const anyRequiredUsers = commandInformation.ReqUsers.length > 0; const anyRequirements = anyRequiredRoles == false && anyRequiredPermissions == false && anyRequiredUsers == false; // Code \\ const getCDStamp = (timestamp = Date.now()) => ``; module.exports = client => { client.on('messageCreate', async message => { if (message.author.bot) return; if (!message.content.toLowerCase().startsWith(Secrets.PREFIX.toLowerCase())) return; const command = message.content.toLowerCase(); const args = command.replace(Secrets.PREFIX.toLowerCase(), '').split(' '); if ( args[0].toString().toLowerCase() == commandInformation.CommandName || commandInformation.Alias.includes(args[0]) ) { // Permit Check \\ let Permited_2 = 0; let Permited_1 = 0; if (anyRequiredUsers) { if (commandInformation.ReqUsers.some(userid => message.author.id == userid)) Permited_1++; } if (anyRequiredPermissions || anyRequiredRoles) { if (anyRequiredPermissions && !Permited_1 >= 1) { if (commandInformation.ReqPermissions.some(permission => message.member.permissions.has(permission))) { Permited_2++; } } if (anyRequiredRoles && Permited_2 <= 0 && !Permited_1 >= 1) { if (commandInformation.ReqRoles.some(role => message.member.roles.cache.has(role))) Permited_2++; } } if (!Permited_1 >= 1 && !Permited_2 >= 1 && anyRequiredUsers) { const promises = commandInformation.ReqUsers.map(async user => await message.guild.members.fetch(user)); const allowedUsersList = await Promise.all(promises); const tags = allowedUsersList.map(m => m.user.tag); return message.reply(`You're not allowed to use this command, only \`${tags.join('`, `')}\` can.`); } else if (!Permited_1 >= 1 && !Permited_2 >= 1 && !anyRequiredUsers) { return message.reply("Sorry, you don't have the required permissions and/or roles."); } if (!Permited_1 >= 1 && !Permited_2 >= 1) { return message.reply("Sorry, you don't have the required permissions and/or roles."); } // Main Code \\ const ReviveCooldown = 1_800_000; // 30 Minutes in ms const cooldownDB = await db.get('ReviveCooldown'); if (cooldownDB > Date.now()) { message.reply(`On cooldown, Can be used after **${getCDStamp(cooldownDB)}**`); } else { await db.set('ReviveCooldown', Date.now() + ReviveCooldown); // 30 mins from now on. message.reply("Wasn't on cooldown! Added cd for next 30mins."); } } }); };