const { MessageEmbed, Permissions } = require('discord.js'); const { red, black } = require('../../other/texts/colors.json'); const { promptMessage, run } = require("../../functions/functions.js"); const { noServerFound } = require("../../other/texts/permissions.json"); const { verified } = require("../../other/texts/emojis.json"); // These are the models that we are going to be requiring to connect to the database. const Server = require("../../models/guilds/server/server.js"); const Verification = require("../../models/guilds/verification/verification.js"); const reaction = ["šŸ‘"]; module.exports = { config: { name: 'applyverified', category: 'settings', usage: 'applyverified', description: 'Apply for the verified server program.', accessableby: 'Administrators' }, run: async (bot, interaction, args) => { if (!interaction.channel.permissionsFor(interaction.guild.me).has([Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES, Permissions.FLAGS.EMBED_LINKS])) return; Server.findOne({ serverID: interaction.guild.id, }, async (err, server) => { if (err) console.log(err); if (!server) { const noServer = new MessageEmbed() .setColor(red) .setDescription(noServerFound) return await interaction.followUp({ embeds: [noServer] }); } else { const embedError = new MessageEmbed() .setColor(red) const mainEmbed = new MessageEmbed() .setColor("#43B581") .setTitle(`${verified} Server Verification Program`) .setDescription("You are about to apply for the **Server Verification Program**. Before doing so, please have a look at our requirements before submitting your server.\n\n**Requirements:**\n• You must have `ADMINISTRATOR` permissions in order to submit your server.\n• Your server must have 250 members or more.\n• Your server must be a public server and not a private server.\n\n*Kindly note that you agree to give us permission to create an invite in your server for our moderators to review your server.*\n\nOnce you meet those requirements, all is left for you is to react with the šŸ‘ reaction and we will take it from there.") .setFooter("Your application may take up to 24 hours to be reviewed.") const m = await interaction.channel.send({ embeds: [mainEmbed] }); const reacted = await run.promptMessage(m, interaction.member, 30, reaction); await m.delete(mainEmbed); if (reacted === "šŸ‘") { if (server.verified === true) { embedError.setDescription("āŒ Your server is already verified."); return await interaction.followUp({ embeds: [embedError] }); }; if (!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) { embedError.setDescription("āŒ You must have `ADMINISTRATOR` permissions in order to submit your server."); return await interaction.followUp({ embeds: [embedError] }); }; if (interaction.guild.memberCount < 1) { embedError.setDescription("āŒ Your server has less than 250 members."); return await interaction.followUp({ embeds: [embedError] }); }; const verification = await Verification.findOne({ serverID: interaction.guild.id }); if (!verification) { const newVerification = new Verification({ serverID: interaction.guild.id }).save().catch(err => console.log(err)); } else { embedError.setDescription("āŒ You have already submitted an application."); return await interaction.followUp({ embeds: [embedError] }); }; let invite = await interaction.channel.createInvite({ maxAge: 172800, maxUses: 5, reason: "Attitude Server Verification" }); const channelEmbed = new MessageEmbed() .setColor(black) .setThumbnail(interaction.guild.iconURL({ dynamic: true, size: 4096, format: 'png' })) .setTitle("New Application") .addField("Server Name", interaction.guild.name, true) .addField("Server ID", interaction.guild.id, true) .addField("Member Count", interaction.guild.memberCount, true) .addField("Invite Link", invite.url, true) await bot.channels.cache.get('828625740773589102').send({ embeds: [channelEmbed] }); const embed = new MessageEmbed() .setColor(black) .setDescription("Your application has been submitted, this may take up to 24 hours.") return await interaction.followUp({ embeds: [embed] }); }; }; }); }, };