diff --git a/commands/check.js b/commands/check.js index dd75c00..3866c23 100644 --- a/commands/check.js +++ b/commands/check.js @@ -1,7 +1,7 @@ const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js'); const { hypixelApiKey } = require('../config.json'); const { color } = require('../config/options.json'); -const fetch = require('axios') +const axios = require('axios'); module.exports = { name: 'check', @@ -20,10 +20,9 @@ module.exports = { async execute(interaction) { - await interaction.reply({ content: 'This command is currently under development.', ephemeral: true }) - return + await interaction.reply({content: "command is currently under development.", ephemeral: true}) - await interaction.deferReply(); + // await interaction.deferReply(); const ign = interaction.options.getString('ign'); const mojang = "https://api.mojang.com/users/profiles/minecraft/" @@ -32,13 +31,11 @@ module.exports = { const minotar = "https://minotar.net/helm/"; const embedColor = Number(color.replace("#", "0x")); - const userCheck = await fetch(mojang + ign); + const userCheck = await axios.get(mojang + ign); const userUUID = userCheck.data.id; - console.log(userCheck) - - const stats = await fetch(slothPixel + userUUID); - const guildCheck = await fetch(guildAPI + userUUID); + const stats = await axios.get(slothPixel + userUUID); + const guildCheck = await axios.get(guildAPI + userUUID); const head = minotar + ign; if (!ign) { @@ -46,13 +43,6 @@ module.exports = { return } - try { - await fetch(mojang + ign) - } catch (error) { - interaction.reply('That player doesn\'t exist. [Mojang]') - return - } - if (!stats.data.uuid) { interaction.reply('That player doesn\'t exist. [Hypixel]') return diff --git a/events/buttons/guilapply.js b/events/buttons/guilapply.js index 0b99b3d..dd9b3a8 100644 --- a/events/buttons/guilapply.js +++ b/events/buttons/guilapply.js @@ -5,6 +5,8 @@ const { applicationsChannel } = require('../../config/options.json'); const { qu1, qu2, qu3, qu4, qu5, qu6, qu7, qu8 } = require('../../config/questions.json'); const { rq1, rq2, rq3, rq4, rq5, rq6, rq7, rq8 } = require('../../config/questions.json'); const { guildRole } = require('../../config/roles.json') +const mongoose = require('mongoose'); +const guildapp = require('../../schemas/guildAppSchema.js'); const path = require('path'); const fetch = require('axios'); const fs = require('fs'); @@ -33,8 +35,9 @@ module.exports = { // return // } - const applicationFile = path.join(__dirname, '../../apps/guild/' + user.id); - if (fs.existsSync(applicationFile)) { + const application = await guildapp.findOne({ userID: user.id }); + + if (application) { await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true }); return } @@ -440,15 +443,16 @@ module.exports = { const userCheck = await fetch(mojangAPI + answer1_1) const uuid = userCheck.data.id - - fs.writeFile(`./apps/guild/${user.id}`, uuid, function (err) { - if (err) throw err; - }); - await user.deleteDM(); - + const newGuildApp = new guildapp({ + _id: new mongoose.Types.ObjectId(), + userID: user.id, + uuid: uuid, + }) + + await newGuildApp.save() + const channel = guild.channels.cache.get(applicationsChannel); - await channel.send({ embeds: [{ title: user.username + "#" + user.discriminator + " - Guild Application", diff --git a/events/buttons/guildapplicationaccept.js b/events/buttons/guildapplicationaccept.js index 04374be..a5b6eed 100644 --- a/events/buttons/guildapplicationaccept.js +++ b/events/buttons/guildapplicationaccept.js @@ -1,5 +1,7 @@ const { ActionRowBuilder, ButtonStyle, ButtonBuilder } = require('discord.js'); const { color } = require('../../config/options.json'); +const mongoose = require('mongoose'); +const guildapp = require('../../schemas/guildAppSchema.js'); const fs = require('fs'); const path = require('path'); @@ -53,7 +55,7 @@ module.exports = { }] }); - fs.rmSync(applicationFile) + await guildapp.findOneAndDelete({ userID: applicantId }); await interaction.editReply({ embeds: [{ diff --git a/events/modals/denyreasonbox.js b/events/modals/denyreasonbox.js index afe82fc..a42ae7c 100644 --- a/events/modals/denyreasonbox.js +++ b/events/modals/denyreasonbox.js @@ -1,5 +1,7 @@ -const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder } = require('discord.js'); +const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const { color } = require('../../config/options.json'); +const mongoose = require('mongoose'); +const guildapp = require('../../schemas/guildAppSchema.js'); const fs = require('fs'); const path = require('path'); @@ -55,7 +57,7 @@ module.exports = { await applicant.send({ embeds: [dmMessage] }); - fs.rmSync(filePath); + await guildapp.findOneAndDelete({ userID: applicantId }); await interaction.editReply({ embeds: [{ diff --git a/package-lock.json b/package-lock.json index 2c15a05..a25314d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1205,6 +1205,25 @@ "node": ">=14" } }, + "node_modules/minecraft-protocol/node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/minecraft-protocol/node_modules/readable-stream": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.3.0.tgz", @@ -1219,6 +1238,25 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/minecraft-protocol/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/minecraft-protocol/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/minecraft-protocol/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/mineflayer": { "version": "4.8.1", "resolved": "https://registry.npmjs.org/mineflayer/-/mineflayer-4.8.1.tgz", @@ -1374,44 +1412,6 @@ "node": ">= 0.6" } }, - "node_modules/node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/node-fetch/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/node-fetch/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/node-fetch/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/node-rsa": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-0.4.2.tgz", @@ -1494,6 +1494,44 @@ "uuid-1345": "^1.0.2" } }, + "node_modules/prismarine-auth/node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/prismarine-auth/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/prismarine-auth/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/prismarine-auth/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/prismarine-biome": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/prismarine-biome/-/prismarine-biome-1.3.0.tgz", @@ -1593,6 +1631,44 @@ "node-fetch": "^2.6.1" } }, + "node_modules/prismarine-realms/node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/prismarine-realms/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/prismarine-realms/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/prismarine-realms/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/prismarine-recipe": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/prismarine-recipe/-/prismarine-recipe-1.3.1.tgz", @@ -2281,6 +2357,44 @@ "node-fetch": "^2.6.1", "uuid": "^8.2.0" } + }, + "node_modules/yggdrasil/node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/yggdrasil/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/yggdrasil/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/yggdrasil/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } } } } diff --git a/schemas/guildAppSchema.js b/schemas/guildAppSchema.js new file mode 100644 index 0000000..7069cc4 --- /dev/null +++ b/schemas/guildAppSchema.js @@ -0,0 +1,9 @@ +const { Schema, model } = require('mongoose'); + +const guildAppSchema = new Schema({ + _id: Schema.Types.ObjectId, + userID: { type: String, required: true }, + uuid: { type: String, required: true }, +}); + +module.exports = model('guildapp', guildAppSchema, 'guildapp'); \ No newline at end of file