const { Client, CommandInteraction, MessageEmbed } = require('discord.js'); const Schema = require('../../Models/premiumSchema'); module.exports = { name: 'interactionCreate', /** * * @param {CommandInteraction} interaction * @param {Client} client */ async execute(interaction, client) { if(interaction.isCommand()) { const command = client.commands.get(interaction.commandName); const premiumCommands = ["test"]; try { await Schema.findOne({ GuildID: interaction.guild.id }, async (err, data) => { if(err) throw err; if(data == null && premiumCommands.some(commands => commands == command.name)) return interaction.reply({content: `${interaction.user} the cmd you tried to use is only available to premium servers.`, ephemeral: true}); if(data) { if(data.Redeemed == false && premiumCommands.some(commands => commands == command.name)) return interaction.reply({content: `${interaction.user} premium has not been redeemed!`, ephemeral: true}); } command.execute(interaction, client) }); } catch (error) { const Logs = interaction.guild.channels.cache.get('934542866179571742'); // Note: You will get a database error (MongooseError: Query was already executed:) just ignore it, the bot still works fine. const errorEmbed = new MessageEmbed() .setColor('RED') .setDescription(`⛔ Alert: ${error}`); Logs.send({ embeds: [errorEmbed], ephemeral: true }); } if(!command) return interaction.reply({embeds: [ new MessageEmbed() .setColor('RED') .setDescription('⛔ An error occured while running this command') ]}) && client.commands.delete(interaction.commandName); command.execute(interaction, client) } } }