Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ptero = require("pterodactyl.js");
- const { SlashCommandBuilder, EmbedBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require("discord.js");
- const Schema = require("../../Modals/account");
- const preRegister = require("../../Modals/pre-register");
- module.exports = {
- data: new SlashCommandBuilder()
- .setName("hosting")
- .setDescription("Hosting manager")
- .addSubcommandGroup(group => group
- .setName("account")
- .setDescription("Create/Delete an account")
- .addSubcommand(command => command
- .setName("create")
- .setDescription("Create an pterodactyl account")
- .addStringOption(option => option.setName("username").setDescription("Your username").setMinLength(7).setMaxLength(24).setRequired(true))
- .addStringOption(option => option.setName("email").setDescription("Your email").setRequired(true))
- .addStringOption(option => option.setName("password").setDescription("Your password").setRequired(true).setMinLength(8).setMaxLength(24))
- )
- .addSubcommand(command => command
- .setName("delete")
- .setDescription("Delete your pterodactyl account")
- .addStringOption(option => option.setName("username").setDescription("Your username").setMaxLength(24).setMinLength(7).setRequired(true))
- .addStringOption(option => option.setName("password").setDescription("Your password").setMaxLength(24).setMinLength(8).setRequired(true))
- )
- )
- .addSubcommandGroup(group => group
- .setName("server")
- .addSubcommand(command => command
- .setName("create")
- .setDescription("Create a server")
- .addStringOption(option => option.setName("name").setDescription("Your servers name").setMinLength(7).setMaxLength(24).setRequired(true))
- .addStringOption(option => option
- .setName("type")
- .setDescription("The type you need")
- .setRequired(true)
- .addChoices(
- {name: "NodeJS", value: "NodeJS"},
- {name: "Python", value: "Python"},
- {name: "Java/JDA", value: "Java"}
- )
- )
- )
- .addSubcommand(command => command
- .setName("status")
- .setDescription("get infos about your server")
- .addStringOption(option => option.setName("server-id").setDescription("please fill in your server url (https://panel.nexus-hosting.com/server/your-id)").setRequired(true))
- )
- .addSubcommand(command => command
- .setName("delete")
- .setDescription("Delete a server")
- .addStringOption(option => option.setName("server-id").setDescription("Delete a server with the id").setRequired(true))
- )
- ),
- async execute (interaction, client) {
- const {user, member, options} = interaction;
- const c = options.getSubcommand()
- const g = options.getSubcommandGroup();
- const registers = await preRegister.findOne({ID: "Testing"});
- function checkEmail (email) {
- const types = [
- "@gmail.com",
- "@proton.me",
- "@gmx.de",
- "@gmx.net",
- "@gmx.ch",
- "@gmx.at",
- "@web.de",
- "@icloud.com",
- "@yahoo.com",
- "@jason-dev.tech",
- "@nexus-hosting.tech",
- ]
- const isValidEmail = types.some(domain => email.endsWith(domain));
- return isValidEmail;
- }
- function checkPassword(password) {
- if (password.length >= 8 && password.length <= 24) {
- if (/[!@#$%^&*()-_=+[ \]{};:'",.<>?/\\|`~]/.test(password)) {
- if (/\d/.test(password)) {
- if (/[A-Z]/.test(password)) {
- return true;
- }
- }
- }
- }
- return false;
- }
- switch (g) {
- case "account":
- switch (c) {
- case "create":
- const mail = options.getString("email");
- const username = options.getString("username");
- const password = options.getString("password");
- if (!registers) {
- await registers.create({ID: "Testing", Count: 1});
- } else {
- let count = registers.Count;
- if (count >= 10) {
- await interaction.reply({
- content: "Sorry, but there is no more pre register place for you :(",
- ephemeral: true
- })
- }
- count++;
- await registers.deleteOne({ID: "Testing"});
- await registers.create({
- Count: count,
- ID: "Testing"
- })
- }
- const mailCheck = checkEmail(mail);
- const passCheck = checkPassword(password)
- if (!mailCheck.isValidEmail) {
- await interaction.reply({
- content: `\`${mail}\` is not a valid email!`,
- ephemeral: true
- })
- }
- if (!passCheck) {
- const embed = new EmbedBuilder()
- .setDescription("Please use at least: \n- 1 Number \n- 1 Special Letter \n- 1 Cap letter \n- Min. 8 placeholders \n- Max. 24 Placeholders")
- await interaction.reply({
- embeds: [embed],
- ephemeral: true
- })
- }
- const data = await Schema.findOne({ UserID: user.id })
- const data2 = await Schema.findOne({ Username: username });
- const data3 = await Schema.findOne({ Email: mail })
- if (data) {
- await interaction.reply({
- content: "You already have an account!",
- ephemeral: true
- })
- } else if (data2) {
- await interaction.reply({
- content: `An account with the name __***${username}***__ already exists!`
- })
- } else if (data3) {
- await interaction.reply({
- content: "Sorry, this email already has been used!",
- ephemeral: true
- })
- }
- const embed = new EmbedBuilder()
- .setTitle("Account Created")
- .setColor("White")
- .addFields(
- {name: "Username:", value: `||${username}||`, inline: true},
- {name: "Email:", value: `||${mail}||`, inline: true},
- {name: "Password:", value: `||${password}||`, inline: true}
- )
- try {
- await Schema.create({
- UserID: member.id,
- Username: username,
- Email: mail,
- Coins: 0,
- Password: password,
- ServerMax: 3,
- TwoFA: false,
- RamMax: "512 MB",
- CPUcoresMax: 2,
- CPUUsageMax: 50,
- })
- await interaction.reply({
- embeds: [embed],
- ephemeral: true
- })
- await user.send({
- embeds: [embed]
- })
- } catch (err) {
- console.log(err);
- }
- break;
- case "delete":
- break;
- }
- break;
- case "server":
- await interaction.reply({
- content: "Sorry, this is currently under development!"
- })
- switch (c) {
- case "create":
- break;
- case "status":
- break;
- case "delete":
- break;
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment