From 510f6afd232cc9143405210c1a277c6c41002b5e Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 24 Apr 2023 22:02:52 +0000 Subject: [PATCH] Revert "Beautifying" This reverts commit 3a3bb89635e103c025c6e298cec59bf4df76b902 --- commands-contextmenu/congratsmessage.js | 64 +- commands-contextmenu/resetnick.js | 77 +- commands-testing/functest.js | 79 +- commands-testing/mute.js | 333 +++---- commands/check.js | 334 +++---- commands/config.js | 248 +++-- commands/devel.js | 183 ++-- commands/forceupdate.js | 507 +++++----- commands/forceverify.js | 351 ++++--- commands/help.js | 96 +- commands/reqs.js | 103 +- commands/send.js | 105 +-- commands/setnick.js | 77 +- commands/slowmode.js | 107 +-- commands/update.js | 462 +++++---- commands/verify.js | 337 ++++--- commands/whois.js | 106 +-- config/limitmessages.json | 8 +- config/options.json | 12 +- config/questions.json | 58 +- config/reqs.json | 12 +- config/roles.json | 28 +- deploy-commands.js | 165 ++-- events/buttons/checkstats.js | 276 +++--- events/buttons/guilapply.js | 1095 ++++++++++------------ events/buttons/guildapplicationaccept.js | 130 ++- events/buttons/guildapplicationdeny.js | 58 +- events/buttons/staffapplicationaccept.js | 117 ++- events/buttons/staffapplicationdeny.js | 48 +- events/buttons/staffapply.js | 918 ++++++++---------- events/modals/denyreasonbox.js | 153 ++- events/modals/staffdenyreasonbox.js | 144 ++- index.js | 354 ++++--- schemas/guildAppSchema.js | 10 +- schemas/staffAppSchema.js | 10 +- schemas/verifySchema.js | 10 +- utils/functions.js | 32 +- utils/mineflayer/limbo.js | 17 +- utils/mineflayer/logmessages.js | 40 +- utils/mineflayer/online.js | 16 +- 40 files changed, 3329 insertions(+), 3951 deletions(-) diff --git a/commands-contextmenu/congratsmessage.js b/commands-contextmenu/congratsmessage.js index 7f2f0ad..3091964 100644 --- a/commands-contextmenu/congratsmessage.js +++ b/commands-contextmenu/congratsmessage.js @@ -1,46 +1,34 @@ -const { - ContextMenuCommandBuilder, - ApplicationCommandType, - PermissionFlagsBits, - userMention -} = require("discord.js"); +const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention} = require('discord.js'); module.exports = { - name: "congratsmessage", - description: "Congratulate a user.", - type: "contextmenu", + name: 'congratsmessage', + description: 'Congratulate a user.', + type: 'contextmenu', - data: new ContextMenuCommandBuilder() - .setName("Congratulate") - .setType(ApplicationCommandType.Message) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), + data: new ContextMenuCommandBuilder() + .setName('Congratulate') + .setType(ApplicationCommandType.Message) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), - async execute(interaction) { - const { targetId } = interaction; - const message = await interaction.channel.messages.fetch(targetId); + async execute(interaction) { - if (!message) { - return interaction.reply({ - content: "That user does not exist.", - ephemeral: true - }); - } + const { targetId } = interaction + const message = await interaction.channel.messages.fetch(targetId); - const target = message.author; - - await message.reply({ - embeds: [ - { - title: "Congratulations!", - description: `GG to ${userMention(target.id)}!` + if (!message) { + return interaction.reply({ content: 'That user does not exist.', ephemeral: true }); } - ] - }); - await message.react("🎉"); - await interaction.reply({ - content: `Sent a congrats message`, - ephemeral: true - }); - } -}; + const target = message.author; + + await message.reply({ + embeds:[{ + title: 'Congratulations!', + description: `GG to ${userMention(target.id)}!`, + }] + }); + await message.react('🎉'); + + await interaction.reply({ content: `Sent a congrats message`, ephemeral: true }); + } +}; \ No newline at end of file diff --git a/commands-contextmenu/resetnick.js b/commands-contextmenu/resetnick.js index c750d13..9344417 100644 --- a/commands-contextmenu/resetnick.js +++ b/commands-contextmenu/resetnick.js @@ -1,55 +1,34 @@ -const { - ContextMenuCommandBuilder, - ApplicationCommandType, - PermissionFlagsBits -} = require("discord.js"); +const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } = require('discord.js'); module.exports = { - name: "resetnick", - description: "Reset your nickname.", - type: "contextmenu", + name: 'resetnick', + description: 'Reset your nickname.', + type: 'contextmenu', - data: new ContextMenuCommandBuilder() - .setName("Reset Nickname") - .setType(ApplicationCommandType.User) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames), + data: new ContextMenuCommandBuilder() + .setName('Reset Nickname') + .setType(ApplicationCommandType.User) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames), - async execute(interaction) { - const { targetId } = interaction; - const target = await interaction.guild.members.fetch(targetId); + async execute(interaction) { - if (!target) { - return interaction.reply({ - content: "That user does not exist.", - ephemeral: true - }); + const { targetId } = interaction + const target = await interaction.guild.members.fetch(targetId); + + if (!target) { + return interaction.reply({ content: 'That user does not exist.', ephemeral: true }); + } + + if (target.id === interaction.user.id) { + return interaction.reply({ content: 'You can\'t reset your own nickname.', ephemeral: true }); + } + + if (!target.manageable) { + return interaction.reply({ content: 'I cannot reset that user\'s nickname.', ephemeral: true }); + } + + await target.setNickname(target.user.username, 'Reset by ' + interaction.user.username + "#" + interaction.user.discriminator); + + return interaction.reply({ content: `Reset ${target.user.username}'s nickname.`, ephemeral: true }); } - - if (target.id === interaction.user.id) { - return interaction.reply({ - content: "You can't reset your own nickname.", - ephemeral: true - }); - } - - if (!target.manageable) { - return interaction.reply({ - content: "I cannot reset that user's nickname.", - ephemeral: true - }); - } - - await target.setNickname( - target.user.username, - "Reset by " + - interaction.user.username + - "#" + - interaction.user.discriminator - ); - - return interaction.reply({ - content: `Reset ${target.user.username}'s nickname.`, - ephemeral: true - }); - } -}; +}; \ No newline at end of file diff --git a/commands-testing/functest.js b/commands-testing/functest.js index 3f3d750..ae97c49 100644 --- a/commands-testing/functest.js +++ b/commands-testing/functest.js @@ -1,44 +1,49 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const getuuid = require("../utils/functions"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const getuuid = require('../utils/functions'); module.exports = { - name: "functest", - description: "Test command for the bot.", - type: "slash", + name: 'functest', + description: 'Test command for the bot.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("functest") - .setDescription("Test command for the bot.") - .addStringOption((option) => - option.setName("test").setDescription("Test option.") - ) - .addStringOption((option) => - option.setName("test2").setDescription("Test option.") - ) - .addStringOption((option) => - option.setName("test3").setDescription("Test option.") - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('functest') + .setDescription('Test command for the bot.') + .addStringOption(option => + option + .setName('test') + .setDescription('Test option.')) + .addStringOption(option => + option + .setName('test2') + .setDescription('Test option.')) + .addStringOption(option => + option + .setName('test3') + .setDescription('Test option.')) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), - async execute(interaction) { - const test = interaction.options.getString("test"); - const test2 = interaction.options.getString("test2"); - const test3 = interaction.options.getString("test3"); + async execute(interaction) { - const uuid = await getuuid(test); + const test = interaction.options.getString('test'); + const test2 = interaction.options.getString('test2'); + const test3 = interaction.options.getString('test3'); + + const uuid = await getuuid(test); + + if (uuid === null) { + await interaction.reply({ + content: 'Invalid username.', + ephemeral: true + }); + return + } + + await interaction.reply({ + content: uuid, + ephemeral: true + }); - if (uuid === null) { - await interaction.reply({ - content: "Invalid username.", - ephemeral: true - }); - return; } - - await interaction.reply({ - content: uuid, - ephemeral: true - }); - } -}; +}; \ No newline at end of file diff --git a/commands-testing/mute.js b/commands-testing/mute.js index 7e1a2d6..607cbed 100644 --- a/commands-testing/mute.js +++ b/commands-testing/mute.js @@ -1,197 +1,162 @@ -const { - SlashCommandBuilder, - PermissionFlagsBits, - userMention -} = require("discord.js"); -const env = require("dotenv").config(); +const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); +const env = require('dotenv').config(); const dev = process.env.DEV; -const { color } = require("../config/options.json"); -const { admin, helper, muted } = require("../config/roles.json"); -const { staffOtherChannel } = require("../config/options.json"); +const { color } = require('../config/options.json'); +const { admin, helper, muted } = require('../config/roles.json'); +const { staffOtherChannel } = require('../config/options.json'); module.exports = { - name: "mute", - description: "Mute a user", - type: "slash", + name: 'mute', + description: 'Mute a user', + type: 'slash', - data: new SlashCommandBuilder() - .setName("mute") - .setDescription("Mute a user") - .addUserOption((option) => - option - .setName("user") - .setDescription("The user to mute") - .setRequired(true) - ) - .addStringOption((option) => - option.setName("reason").setDescription("The reason for the mute") - ) - .addStringOption((option) => - option.setName("duration").setDescription("The duration of the mute") - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('mute') + .setDescription('Mute a user') + .addUserOption(option => + option + .setName('user') + .setDescription('The user to mute') + .setRequired(true)) + .addStringOption(option => + option + .setName('reason') + .setDescription('The reason for the mute')) + .addStringOption(option => + option + .setName('duration') + .setDescription('The duration of the mute')) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), - async execute(interaction) { - const member1 = interaction.options.getUser("user"); - const member = interaction.guild.members.cache.get(member1.id); - const reason = - interaction.options.getString("reason") ?? "No reason provided"; - const duration = interaction.options.getString("duration"); - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); + async execute(interaction) { - const userRoles = await guild.members - .fetch(interaction.user.id) - .then((member) => member.roles.cache.map((role) => role.id)); - const memberRoles = await guild.members - .fetch(member1.id) - .then((member) => member.roles.cache.map((role) => role.id)); + const member1 = interaction.options.getUser('user'); + const member = interaction.guild.members.cache.get(member1.id); + const reason = interaction.options.getString('reason') ?? 'No reason provided'; + const duration = interaction.options.getString('duration'); + const guild = interaction.guild; + const embedColor = Number(color.replace('#', '0x')); - await interaction.deferReply({}); + const userRoles = await guild.members.fetch(interaction.user.id).then(member => member.roles.cache.map(role => role.id)); + const memberRoles = await guild.members.fetch(member1.id).then(member => member.roles.cache.map(role => role.id)); - if (!userRoles.includes(admin || helper)) { - await interaction.editReply({ - embeds: [ - { - description: "You don't have permission to use this command.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - } - ] - }); - return; - } + await interaction.deferReply({}); - if (member.id === interaction.user.id) { - await interaction.editReply({ - embeds: [ - { - description: "You can't mute yourself.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - } - ] - }); - return; - } - - if (member.id === dev) { - await interaction.editReply({ - embeds: [ - { - description: "You can't mute my developer.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - } - ] - }); - return; - } - - // if (memberRoles.includes(admin) || memberRoles.includes(helper)) { - // await interaction.editReply({ - // embeds: [{ - // description: "You can't mute a staff member.", - // color: embedColor, - // footer: { - // text: interaction.guild.name + " | Developed by @Taken#0002", - // icon_url: interaction.guild.iconURL({ dynamic: true }) - // } - // }] - // }); - // return - // } - - if (!duration) { - await member.roles.add(muted, reason); - await interaction.editReply({ - embeds: [ - { - description: - "Successfully muted " + userMention(member1.id) + " forever.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - } - ] - }); - return; - } - - console.log(duration); - - const weeks = duration.replace(/[0-9][dhms]/g, "").replace(/w/g, ""); - const days = duration.replace(/[0-9][whms]/g, "").replace(/d/g, ""); - const hours = duration.replace(/[0-9][wdms]/g, "").replace(/h/g, ""); - const minutes = duration.replace(/[0-9][wdhs]/g, "").replace(/m/g, ""); - const seconds = duration.replace(/[0-9][wdhm]/g, "").replace(/s/g, ""); - - const nweeks = Number(weeks) ?? 0; - const ndays = Number(days) ?? 0; - const nhours = Number(hours) ?? 0; - const nminutes = Number(minutes) ?? 0; - const nseconds = Number(seconds) ?? 0; - - const time = - nweeks * 604800000 + - ndays * 86400000 + - nhours * 3600000 + - nminutes * 60000 + - nseconds * 1000; - const mutedTime = - (nweeks > 0 ? nweeks + " week(s), " : "") + - (ndays > 0 ? ndays + " day(s), " : "") + - (nhours > 0 ? nhours + " hour(s), " : "") + - (nminutes > 0 ? nminutes + " minute(s), " : "") + - (nseconds > 0 ? nseconds + " second(s)" : ""); - - await member.roles.add(muted, reason); - await interaction.editReply({ - embeds: [ - { - description: - "Successfully muted " + - userMention(member1.id) + - " for " + - mutedTime + - ".", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } + if (!userRoles.includes(admin || helper)) { + await interaction.editReply({ + embeds: [{ + description: "You don't have permission to use this command.", + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }); + return } - ] - }); - const logChannel = interaction.guild.channels.cache.get(staffOtherChannel); + if (member.id === interaction.user.id) { + await interaction.editReply({ + embeds: [{ + description: "You can't mute yourself.", + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }); + return + } - setTimeout(async () => { - await member.roles.remove(muted, "Mute duration has ended."); - await logChannel.send({ - embeds: [ - { - description: userMention(member1.id) + " has been unmuted.", - color: embedColor, - footer: { - text: "ID: " + member1.id, - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - } - ] - }); - }, time); - } + if (member.id === dev) { + await interaction.editReply({ + embeds: [{ + description: "You can't mute my developer.", + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }); + return + } + + // if (memberRoles.includes(admin) || memberRoles.includes(helper)) { + // await interaction.editReply({ + // embeds: [{ + // description: "You can't mute a staff member.", + // color: embedColor, + // footer: { + // text: interaction.guild.name + " | Developed by @Taken#0002", + // icon_url: interaction.guild.iconURL({ dynamic: true }) + // } + // }] + // }); + // return + // } + + if (!duration) { + await member.roles.add(muted, reason); + await interaction.editReply({ + embeds: [{ + description: "Successfully muted " + userMention(member1.id) + " forever.", + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } + + console.log(duration); + + const weeks = duration.replace(/[0-9][dhms]/g, '').replace(/w/g, '') + const days = duration.replace(/[0-9][whms]/g, '').replace(/d/g, '') + const hours = duration.replace(/[0-9][wdms]/g, '').replace(/h/g, '') + const minutes = duration.replace(/[0-9][wdhs]/g, '').replace(/m/g, '') + const seconds = duration.replace(/[0-9][wdhm]/g, '').replace(/s/g, '') + + const nweeks = Number(weeks) ?? 0; + const ndays = Number(days) ?? 0; + const nhours = Number(hours) ?? 0; + const nminutes = Number(minutes) ?? 0; + const nseconds = Number(seconds) ?? 0; + + const time = nweeks * 604800000 + ndays * 86400000 + nhours * 3600000 + nminutes * 60000 + nseconds * 1000; + const mutedTime = (nweeks > 0 ? nweeks + " week(s), " : "") + (ndays > 0 ? ndays + " day(s), " : "") + (nhours > 0 ? nhours + " hour(s), " : "") + (nminutes > 0 ? nminutes + " minute(s), " : "") + (nseconds > 0 ? nseconds + " second(s)" : ""); + + await member.roles.add(muted, reason); + await interaction.editReply({ + embeds: [{ + description: "Successfully muted " + userMention(member1.id) + " for " + mutedTime + ".", + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }); + + const logChannel = interaction.guild.channels.cache.get(staffOtherChannel); + + setTimeout(async () => { + await member.roles.remove(muted, "Mute duration has ended."); + await logChannel.send({ + embeds: [{ + description: userMention(member1.id) + " has been unmuted.", + color: embedColor, + footer: { + text: "ID: " + member1.id, + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + }, time); + } }; diff --git a/commands/check.js b/commands/check.js index 64572c9..6682f3f 100644 --- a/commands/check.js +++ b/commands/check.js @@ -1,203 +1,147 @@ -const { - SlashCommandBuilder, - EmbedBuilder, - PermissionFlagsBits -} = require("discord.js"); -const { - bwfdkr, - bwstars, - bwwins, - duelswins, - swstars -} = require("../config/reqs.json"); -const getuuid = require("../utils/functions"); -const env = require("dotenv").config(); +const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js'); +const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../config/reqs.json') +const getuuid = require('../utils/functions'); +const env = require('dotenv').config(); const hypixelApiKey = process.env.HYPIXELAPI; -const { color } = require("../config/options.json"); -const fetch = require("axios"); +const { color } = require('../config/options.json'); +const fetch = require('axios'); module.exports = { - name: "check", - description: "Check a player's stats.", - type: "slash", + name: 'check', + description: 'Check a player\'s stats.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("check") - .setDescription("Check a player's stats.") - .addStringOption((option) => - option - .setName("ign") - .setDescription("The player's IGN.") - .setRequired(true) - ) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('check') + .setDescription('Check a player\'s stats.') + .addStringOption(option => + option + .setName('ign') + .setDescription('The player\'s IGN.') + .setRequired(true)) + .setDMPermission(false), - async execute(interaction) { - await interaction.deferReply({}); + async execute(interaction) { - const ign = interaction.options.getString("ign"); - const mojang = "https://api.mojang.com/users/profiles/minecraft/"; - const slothPixel = "https://api.slothpixel.me/api/players/"; - const guildAPI = "https://api.slothpixel.me/api/guilds/"; - const minotar = "https://minotar.net/helm/"; - const embedColor = Number(color.replace("#", "0x")); + await interaction.deferReply({}) - if (!ign) { - await interaction.editReply("Please provide a player's IGN."); - return; - } - - if ((await getuuid(ign)) === null) { - await interaction.editReply("That player doesn't exist. [Mojang]"); - return; - } - - const userUUID = await getuuid(ign); - - try { - await fetch(slothPixel + userUUID); - } catch (error) { - interaction.editReply("That player doesn't exist. [Hypixel]"); - return; - } - - const stats = await fetch(slothPixel + userUUID); - const head = minotar + ign; - - if (!stats.data.uuid) { - interaction.editReply("That player doesn't exist. [Hypixel]"); - return; - } - - const rank_formatted = stats.data.rank_formatted; - const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, ""); - - if (rank2 === "") { - var rank = ""; - } else { - var rank = rank2 + " "; - } - - try { - const guildCheck = await fetch(guildAPI + userUUID); - var guildName = guildCheck.data.name; - } catch (error) { - var guildName = "None"; - } - - const hsbwstars = stats.data.stats.BedWars.level; - const hsbwfkdr = stats.data.stats.BedWars.final_k_d; - const hsbwwins = stats.data.stats.BedWars.wins; - const hsswstars = stats.data.stats.SkyWars.level; - const hsduelswins = stats.data.stats.Duels.general.wins; - - if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) { - var bwtitle = - " This player does not meet the BedWars requirements."; - } else { - var bwtitle = - " This player meets the BedWars requirements."; - } - - if (hsswstars < swstars) { - var swtitle = - " This player does not meet the SkyWars requirements."; - } else { - var swtitle = - " This player meets the SkyWars requirements."; - } - - if (hsduelswins < duelswins) { - var duelstitle = - " This player does not meet the Duels requirements."; - } else { - var duelstitle = - " This player meets the Duels requirements."; - } - - try { - const guildCheck = await fetch(guildAPI + userUUID); - const tag_formatted = guildCheck.data.tag_formatted; - const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, ""); - var guildTag = " " + guildTag2; - } catch (error) { - var guildTag = ""; - } - - await interaction.editReply({ - embeds: [ - { - title: rank + stats.data.username + guildTag, - description: - "**Network Level:** `" + - stats.data.level.toString() + - "`\n" + - "**Current Guild:** `" + - guildName + - "`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL() - }, - fields: [ - { - name: bwtitle, - value: - "**➺ Stars:** `" + - stats.data.stats.BedWars.level.toString() + - " / " + - bwstars.toString() + - "`\n" + - "**➺ FKDR:** `" + - stats.data.stats.BedWars.final_k_d.toString() + - " / " + - bwfdkr.toString() + - "`\n" + - "**➺ Wins:** `" + - stats.data.stats.BedWars.wins.toString() + - " / " + - bwwins.toString() + - "`" - }, - { - name: swtitle, - value: - "**➺ Stars:** `" + - stats.data.stats.SkyWars.level.toFixed(2).toString() + - " / " + - swstars.toString() + - "`\n" + - "**➺ KDR:** `" + - stats.data.stats.SkyWars.kill_death_ratio.toString() + - "`\n" + - "**➺ Wins:** `" + - stats.data.stats.SkyWars.wins.toString() + - "`" - }, - { - name: duelstitle, - value: - "**➺ Wins:** `" + - stats.data.stats.Duels.general.wins.toString() + - " / " + - duelswins.toString() + - "`\n" + - "**➺ KDR:** `" + - stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + - "`\n" + - "**➺ WLR:** `" + - stats.data.stats.Duels.general.win_loss_ratio - .toFixed(2) - .toString() + - "`" - } - ] + const ign = interaction.options.getString('ign'); + const mojang = "https://api.mojang.com/users/profiles/minecraft/" + const slothPixel = "https://api.slothpixel.me/api/players/"; + const guildAPI = "https://api.slothpixel.me/api/guilds/" + const minotar = "https://minotar.net/helm/"; + const embedColor = Number(color.replace("#", "0x")); + + if (!ign) { + await interaction.editReply('Please provide a player\'s IGN.') + return } - ] - }); - } -}; + + if (await getuuid(ign) === null) { + await interaction.editReply('That player doesn\'t exist. [Mojang]') + return + } + + const userUUID = await getuuid(ign); + + try { + await fetch(slothPixel + userUUID); + } catch (error) { + interaction.editReply('That player doesn\'t exist. [Hypixel]') + return + } + + const stats = await fetch(slothPixel + userUUID); + const head = minotar + ign; + + if (!stats.data.uuid) { + interaction.editReply('That player doesn\'t exist. [Hypixel]') + return + } + + const rank_formatted = stats.data.rank_formatted + const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, "") + + if (rank2 === "") { + var rank = "" + } else { + var rank = rank2 + " " + } + + try { + const guildCheck = await fetch(guildAPI + userUUID); + var guildName = guildCheck.data.name + } catch (error) { + var guildName = "None" + } + + const hsbwstars = stats.data.stats.BedWars.level + const hsbwfkdr = stats.data.stats.BedWars.final_k_d + const hsbwwins = stats.data.stats.BedWars.wins + const hsswstars = stats.data.stats.SkyWars.level + const hsduelswins = stats.data.stats.Duels.general.wins + + if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) { + var bwtitle = " This player does not meet the BedWars requirements." + } else { + var bwtitle = " This player meets the BedWars requirements." + } + + if (hsswstars < swstars) { + var swtitle = " This player does not meet the SkyWars requirements." + } else { + var swtitle = " This player meets the SkyWars requirements." + } + + if (hsduelswins < duelswins) { + var duelstitle = " This player does not meet the Duels requirements." + } else { + var duelstitle = " This player meets the Duels requirements." + } + + try { + const guildCheck = await fetch(guildAPI + userUUID); + const tag_formatted = guildCheck.data.tag_formatted + const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "") + var guildTag = " " + guildTag2 + } catch (error) { + var guildTag = "" + } + + await interaction.editReply({ + embeds: [{ + title: rank + stats.data.username + guildTag, + description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + + "**Current Guild:** `" + guildName + "`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL() + }, + fields: [ + { + name: bwtitle, + value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + " / " + bwstars.toString() + "`\n" + + "**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + " / " + bwfdkr.toString() + "`\n" + + "**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + " / " + bwwins.toString() + "`" + }, + { + name: swtitle, + value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + " / " + swstars.toString() + "`\n" + + "**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" + + "**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`" + }, + { + name: duelstitle, + value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + " / " + duelswins.toString() + "`\n" + + "**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + + "**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`" + } + ] + }] + }) + } +}; \ No newline at end of file diff --git a/commands/config.js b/commands/config.js index 2fd1315..61dd08a 100644 --- a/commands/config.js +++ b/commands/config.js @@ -1,145 +1,125 @@ -const { - SlashCommandBuilder, - PermissionFlagsBits, - ButtonBuilder, - ActionRowBuilder, - ButtonStyle, - EmbedBuilder, - WebhookClient -} = require("discord.js"); -const { title } = require("process"); -const { color } = require("../config/options.json"); +const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder, WebhookClient } = require('discord.js'); +const { title } = require('process'); +const { color } = require('../config/options.json'); module.exports = { - name: "config", - description: "Configure the bot.", - type: "slash", + name: 'config', + description: 'Configure the bot.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("config") - .setDescription("Configure the bot.") - .addSubcommand((subcommand) => - subcommand - .setName("sendguildapplication") - .setDescription("Send the application message to a channel.") - .addChannelOption((option) => - option - .setName("channel") - .setDescription("The channel to send the application to.") - .setRequired(true) - ) - ) - .addSubcommand((subcommand) => - subcommand - .setName("sendstaffapplication") - .setDescription("Send the application message to a channel.") - .addChannelOption((option) => - option - .setName("channel") - .setDescription("The channel to send the application to.") - .setRequired(true) - ) - ) - .addSubcommand((subcommand) => - subcommand - .setName("sendguildinfo") - .setDescription("Send the guild info message to a channel.") - ) - .addSubcommand((subcommand) => - subcommand - .setName("sendrequirements") - .setDescription("Send the guild requirements message to a channel.") - ) - .addSubcommand((subcommand) => - subcommand - .setName("sendrules-info") - .setDescription("Send the rules and info message to a channel.") - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('config') + .setDescription('Configure the bot.') + .addSubcommand(subcommand => + subcommand + .setName('sendguildapplication') + .setDescription('Send the application message to a channel.') + .addChannelOption(option => + option + .setName('channel') + .setDescription('The channel to send the application to.') + .setRequired(true))) + .addSubcommand(subcommand => + subcommand + .setName('sendstaffapplication') + .setDescription('Send the application message to a channel.') + .addChannelOption(option => + option + .setName('channel') + .setDescription('The channel to send the application to.') + .setRequired(true))) + .addSubcommand(subcommand => + subcommand + .setName('sendguildinfo') + .setDescription('Send the guild info message to a channel.')) + .addSubcommand(subcommand => + subcommand + .setName('sendrequirements') + .setDescription('Send the guild requirements message to a channel.')) + .addSubcommand(subcommand => + subcommand + .setName('sendrules-info') + .setDescription('Send the rules and info message to a channel.')) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), - async execute(interaction) { - const user = interaction.user; - const guild = interaction.guild; - const subcommand = interaction.options.getSubcommand(); - const embedColor = Number(color.replace("#", "0x")); + async execute(interaction) { - if (subcommand === "reload") { - await interaction.reply({ content: "In development", ephemeral: true }); - return; - } + const user = interaction.user; + const guild = interaction.guild; + const subcommand = interaction.options.getSubcommand(); + const embedColor = Number(color.replace("#", "0x")); - if (subcommand === "sendguildapplication") { - const channel = interaction.options.getChannel("channel"); + if (subcommand === 'reload') { - await channel.send({ - embeds: [ - { - title: "Guild Application", - description: - "You can apply for the guild by clicking the button below.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - iconURL: interaction.guild.iconURL({ dynamic: true }) - }, - thumbnail: { - url: interaction.guild.iconURL({ dynamic: true }) - } - } - ], - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("guildapply") - .setLabel("Apply") - .setStyle(ButtonStyle.Primary) - .setEmoji({ name: "✅" }) - ) - ] - }); - await interaction.reply({ content: "Message sent", ephemeral: true }); - } + await interaction.reply({ content: 'In development', ephemeral: true }) + return - if (subcommand === "sendstaffapplication") { - const channel = interaction.options.getChannel("channel"); + } + + if (subcommand === 'sendguildapplication') { - await channel.send({ - embeds: [ - { - title: "Staff Application", - description: - "You can apply for the staff team by clicking the button below.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - iconURL: interaction.guild.iconURL({ dynamic: true }) - }, - thumbnail: { - url: interaction.guild.iconURL({ dynamic: true }) - } - } - ], - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("staffapply") - .setLabel("Apply") - .setStyle(ButtonStyle.Primary) - .setEmoji({ name: "✅" }) - ) - ] - }); + const channel = interaction.options.getChannel('channel'); - await interaction.reply({ content: "Message sent", ephemeral: true }); - } + await channel.send({ + embeds: [{ + title: 'Guild Application', + description: "You can apply for the guild by clicking the button below.", + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + iconURL: interaction.guild.iconURL({ dynamic: true }) + }, + thumbnail: { + url: interaction.guild.iconURL({ dynamic: true }) + } + }], + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId('guildapply') + .setLabel('Apply') + .setStyle(ButtonStyle.Primary) + .setEmoji({ name: '✅' }) + ) + ] + }) + await interaction.reply({ content: 'Message sent', ephemeral: true }) + } - if ( - subcommand !== "sendguildinfo" || - "sendrequirements" || - "sendrules-info" - ) { - await interaction.reply({ content: "In development.", ephemeral: true }); - } - } -}; + if (subcommand === 'sendstaffapplication') { + + const channel = interaction.options.getChannel('channel'); + + await channel.send({ + embeds: [{ + title: 'Staff Application', + description: "You can apply for the staff team by clicking the button below.", + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + iconURL: interaction.guild.iconURL({ dynamic: true }) + }, + thumbnail: { + url: interaction.guild.iconURL({ dynamic: true }) + } + }], + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId('staffapply') + .setLabel('Apply') + .setStyle(ButtonStyle.Primary) + .setEmoji({ name: '✅' }) + ) + ] + }) + + await interaction.reply({ content: 'Message sent', ephemeral: true }) + } + + if (subcommand !== "sendguildinfo" || "sendrequirements" || "sendrules-info") { + await interaction.reply({ content: 'In development.', ephemeral: true }); + } + } +}; \ No newline at end of file diff --git a/commands/devel.js b/commands/devel.js index f335cee..4eb26e6 100644 --- a/commands/devel.js +++ b/commands/devel.js @@ -1,104 +1,105 @@ -const { - SlashCommandBuilder, - PermissionFlagsBits, - userMention, - EmbedBuilder -} = require("discord.js"); -const { hypixelGuildID, color } = require("../config/options.json"); -const verify = require("../schemas/verifySchema.js"); -const env = require("dotenv").config(); +const { SlashCommandBuilder, PermissionFlagsBits, userMention, EmbedBuilder } = require('discord.js'); +const { hypixelGuildID, color } = require('../config/options.json'); +const verify = require('../schemas/verifySchema.js'); +const env = require('dotenv').config(); const dev = process.env.DEV; -const fetch = require("axios"); +const fetch = require('axios'); module.exports = { - name: "admin", - description: "Admin command.", - type: "slash", + name: 'admin', + description: 'Admin command.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("devel") - .setDescription("Admin command.") - .addSubcommand((subcommand) => - subcommand - .setName("dbclearnonguildmembers") - .setDescription("Clears the database of non-guild members.") - ) - .addSubcommand((subcommand) => - subcommand.setName("reload").setDescription("Reload the bot.") - ) - .addSubcommand((subcommand) => - subcommand - .setName("listallverified") - .setDescription("List all verified users.") - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('devel') + .setDescription('Admin command.') + .addSubcommand(subcommand => + subcommand + .setName('dbclearnonguildmembers') + .setDescription('Clears the database of non-guild members.')) + .addSubcommand(subcommand => + subcommand + .setName('reload') + .setDescription('Reload the bot.')) + .addSubcommand(subcommand => + subcommand + .setName('listallverified') + .setDescription('List all verified users.')) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), - async execute(interaction) { - const subcommand = interaction.options.getSubcommand(); - const user = interaction.user; - const userMentioned = userMention(user.id); - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); + async execute(interaction) { - if (subcommand === "dbclearnonguildmembers") { - await interaction.deferReply({ ephemeral: true }); + const subcommand = interaction.options.getSubcommand(); + const user = interaction.user; + const userMentioned = userMention(user.id); + const guild = interaction.guild; + const embedColor = Number(color.replace("#", "0x")); - if (user.id !== dev) { - interaction.editReply({ - content: - "Due to you not screwing something up this command is restricted to only " + - userMentioned, - ephemeral: true - }); - return; - } + if (subcommand === 'dbclearnonguildmembers') { - const slothPixel = "https://api.slothpixel.me/api/guilds/"; - const verifiedUsers = await verify.find(); + await interaction.deferReply({ ephemeral: true }) - verifiedUsers.forEach(async (user) => { - const userGuild = await fetch(slothPixel + user.uuid); + if (user.id !== dev) { + interaction.editReply({ content: 'Due to you not screwing something up this command is restricted to only ' + userMentioned, ephemeral: true }) + return + } + + const slothPixel = "https://api.slothpixel.me/api/guilds/" + const verifiedUsers = await verify.find() + + verifiedUsers.forEach(async (user) => { + + const userGuild = await fetch(slothPixel + user.uuid); + + if (userGuild.data.id !== hypixelGuildID) { + await verify.deleteOne({ uuid: user.uuid }) + } + + }) + + interaction.editReply({ content: 'Done!', ephemeral: true }) + + } + + if (subcommand === 'reload') { + + await interaction.reply({ content: 'In development', ephemeral: true }) + return + + } + + if (subcommand === 'listallverified') { + + const verifiedUsers = await verify.find() + const mojang = "https://api.mojang.com/user/profile/" + + let embed = new EmbedBuilder() + .setTitle(guild.name) + .setColor(embedColor) + .setDescription('List of all verified users') + + for (let i = 0; i < verifiedUsers.length; i++) { + + const user = verifiedUsers[i]; + + const userCheck = await fetch(mojang + user.uuid); + const ign = userCheck.data.name; + + const mentionedUser = userMention(user.userID); + + embed.addFields({ + name: "**IGN:** " + ign, + value: "**Discord:** " + mentionedUser + }) + + } + + await interaction.reply({ + embeds: [embed] + }) - if (userGuild.data.id !== hypixelGuildID) { - await verify.deleteOne({ uuid: user.uuid }); } - }); - interaction.editReply({ content: "Done!", ephemeral: true }); } - - if (subcommand === "reload") { - await interaction.reply({ content: "In development", ephemeral: true }); - return; - } - - if (subcommand === "listallverified") { - const verifiedUsers = await verify.find(); - const mojang = "https://api.mojang.com/user/profile/"; - - let embed = new EmbedBuilder() - .setTitle(guild.name) - .setColor(embedColor) - .setDescription("List of all verified users"); - - for (let i = 0; i < verifiedUsers.length; i++) { - const user = verifiedUsers[i]; - - const userCheck = await fetch(mojang + user.uuid); - const ign = userCheck.data.name; - - const mentionedUser = userMention(user.userID); - - embed.addFields({ - name: "**IGN:** " + ign, - value: "**Discord:** " + mentionedUser - }); - } - - await interaction.reply({ - embeds: [embed] - }); - } - } -}; +}; \ No newline at end of file diff --git a/commands/forceupdate.js b/commands/forceupdate.js index 8fd206b..aaf1848 100644 --- a/commands/forceupdate.js +++ b/commands/forceupdate.js @@ -1,323 +1,266 @@ -const { - SlashCommandBuilder, - PermissionFlagsBits, - userMention -} = require("discord.js"); -const { hypixelGuildID, color } = require("../config/options.json"); -const { - gm, - manager, - moderator, - beast, - member, - trialmember, - guildRole, - guildStaff, - defaultMember -} = require("../config/roles.json"); -const verify = require("../schemas/verifySchema.js"); -const fetch = require("axios"); -const removeThese = [ - gm, - manager, - moderator, - beast, - member, - trialmember, - guildRole, - guildStaff -]; +const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); +const { hypixelGuildID, color } = require('../config/options.json'); +const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); +const verify = require('../schemas/verifySchema.js') +const fetch = require('axios'); +const removeThese = [gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff] module.exports = { - name: "forceupdate", - description: "Force update the user", - type: "slash", + name: 'forceupdate', + description: 'Force update the user', + type: 'slash', - data: new SlashCommandBuilder() - .setName("forceupdate") - .setDescription("Force update the user") - .addUserOption((option) => - option - .setName("user") - .setDescription("The user to force update") - .setRequired(true) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('forceupdate') + .setDescription('Force update the user') + .addUserOption(option => + option + .setName('user') + .setDescription('The user to force update') + .setRequired(true)) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), - async execute(interaction) { - await interaction.deferReply(); + async execute(interaction) { - const user = interaction.options.getUser("user"); - const usermentioned = userMention(user.id); - const guild = interaction.guild; - const verifyData = await verify.findOne({ userID: user.id }); + await interaction.deferReply(); - const user1 = guild.members.cache.get(user.id); - const roleManage = user1.roles; + const user = interaction.options.getUser('user'); + const usermentioned = userMention(user.id); + const guild = interaction.guild; + const verifyData = await verify.findOne({ userID: user.id }) - if (!verifyData) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + const user1 = guild.members.cache.get(user.id); + const roleManage = user1.roles; - await interaction.editReply({ - embeds: [ - { - description: - usermentioned + " was given the the Default Member role.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + if (!verifyData) { + + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - await roleManage.add(defaultMember, "User was force updated."); - return; - } - const slothPixel = "https://api.slothpixel.me/api/players/"; - const guildAPI = "https://api.slothpixel.me/api/guilds/"; - const mojangAPI = "https://api.mojang.com/user/profile/"; - const minotar = "https://minotar.net/helm/"; + await interaction.editReply({ + embeds: [{ + description: usermentioned + " was given the the Default Member role.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + await roleManage.add(defaultMember, "User was force updated.") + return + } - const userCheck = await fetch(mojangAPI + verifyData.uuid); - const hypixelCheck = await fetch(slothPixel + verifyData.uuid); - const head = minotar + userCheck.data.name; + const slothPixel = "https://api.slothpixel.me/api/players/"; + const guildAPI = "https://api.slothpixel.me/api/guilds/" + const mojangAPI = "https://api.mojang.com/user/profile/" + const minotar = "https://minotar.net/helm/"; - try { - const guildCheck = await fetch(guildAPI + verifyData.uuid); - var responseGuildID = guildCheck.data.id; - } catch (err) { - var responseGuildID = null; - } + const userCheck = await fetch(mojangAPI + verifyData.uuid); + const hypixelCheck = await fetch(slothPixel + verifyData.uuid); + const head = minotar + userCheck.data.name; - if (responseGuildID !== hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + try { + const guildCheck = await fetch(guildAPI + verifyData.uuid); + var responseGuildID = guildCheck.data.id; + } catch (err) { + var responseGuildID = null; + } - await interaction.editReply({ - embeds: [ - { - description: - usermentioned + " was given the the Default Member role.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + if (responseGuildID !== hypixelGuildID) { + + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - await roleManage.add(defaultMember); - return; - } - const guildCheck = await fetch(guildAPI + verifyData.uuid); - const embedColor = Number(color.replace("#", "0x")); - const GuildMembers = await guildCheck.data.members; - const guildRank = GuildMembers.find( - (member) => member.uuid === verifyData.uuid - ).rank; + await interaction.editReply({ + embeds: [{ + description: usermentioned + " was given the the Default Member role.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + await roleManage.add(defaultMember) + return + } - if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + const guildCheck = await fetch(guildAPI + verifyData.uuid); + const embedColor = Number(color.replace("#", "0x")); + const GuildMembers = await guildCheck.data.members; + const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank; - await roleManage.add(guildRole, "User was force updated."); - await roleManage.add(guildStaff, "User was force updated."); - await roleManage.add(gm, "User was force updated."); - await roleManage.add(defaultMember, "User was force updated."); + if (guildRank === 'Guild Master' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: - usermentioned + "'s rank has been updated to `Guild Master`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - } + + await roleManage.add(guildRole, "User was force updated.") + await roleManage.add(guildStaff, "User was force updated.") + await roleManage.add(gm, "User was force updated.") + await roleManage.add(defaultMember, "User was force updated.") - if (guildRank === "Manager" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + + await interaction.editReply({ + embeds: [{ + description: usermentioned + "'s rank has been updated to `Guild Master`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + } - await roleManage.add(guildRole, "User was force updated."); - await roleManage.add(guildStaff, "User was force updated."); - await roleManage.add(manager, "User was force updated."); - await roleManage.add(defaultMember, "User was force updated."); + if (guildRank === 'Manager' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: - usermentioned + "'s rank has been updated to `Manager`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - } + + await roleManage.add(guildRole, "User was force updated.") + await roleManage.add(guildStaff, "User was force updated.") + await roleManage.add(manager, "User was force updated.") + await roleManage.add(defaultMember, "User was force updated.") - if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + + await interaction.editReply({ + embeds: [{ + description: usermentioned + "'s rank has been updated to `Manager`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + } - await roleManage.add(guildRole, "User was force updated."); - await roleManage.add(guildStaff, "User was force updated."); - await roleManage.add(moderator, "User was force updated."); - await roleManage.add(defaultMember, "User was force updated."); + if (guildRank === 'Moderator' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: - usermentioned + "'s rank has been updated to `Moderator`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - } + + await roleManage.add(guildRole, "User was force updated.") + await roleManage.add(guildStaff, "User was force updated.") + await roleManage.add(moderator, "User was force updated.") + await roleManage.add(defaultMember, "User was force updated.") - if (guildRank === "Beast" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + + await interaction.editReply({ + embeds: [{ + description: usermentioned + "'s rank has been updated to `Moderator`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) - await roleManage.add(guildRole, "User was force updated."); - await roleManage.add(beast, "User was force updated."); - await roleManage.add(defaultMember, "User was force updated."); + } - await interaction.editReply({ - embeds: [ - { - description: usermentioned + "'s rank has been updated to `Beast`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + if (guildRank === 'Beast' && responseGuildID === hypixelGuildID) { + + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - return; - } + + await roleManage.add(guildRole, "User was force updated.") + await roleManage.add(beast, "User was force updated.") + await roleManage.add(defaultMember, "User was force updated.") - if (guildRank === "Member" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + + await interaction.editReply({ + embeds: [{ + description: usermentioned + "'s rank has been updated to `Beast`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } - await roleManage.add(guildRole, "User was force updated."); - await roleManage.add(member, "User was force updated."); - await roleManage.add(defaultMember, "User was force updated."); + if (guildRank === 'Member' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: - usermentioned + "'s rank has been updated to `Member`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - return; - } + + await roleManage.add(guildRole, "User was force updated.") + await roleManage.add(member, "User was force updated.") + await roleManage.add(defaultMember, "User was force updated.") - if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove( - removeThese[i], - "Auto role removal. (Force Update)" - ); - } + + await interaction.editReply({ + embeds: [{ + description: usermentioned + "'s rank has been updated to `Member`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } - await roleManage.add(guildRole, "User was force updated."); - await roleManage.add(trialmember, "User was force updated."); - await roleManage.add(defaultMember, "User was force updated."); + if (guildRank === 'Trial Member' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: - usermentioned + "'s rank has been updated to `Trial Member`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") } - } - ] - }); - return; + + await roleManage.add(guildRole, "User was force updated.") + await roleManage.add(trialmember, "User was force updated.") + await roleManage.add(defaultMember, "User was force updated.") + + + await interaction.editReply({ + embeds: [{ + description: usermentioned + "'s rank has been updated to `Trial Member`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } } - } -}; +} \ No newline at end of file diff --git a/commands/forceverify.js b/commands/forceverify.js index ffbfa3c..05d5199 100644 --- a/commands/forceverify.js +++ b/commands/forceverify.js @@ -1,195 +1,174 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const env = require("dotenv").config(); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const env = require('dotenv').config(); const hypixelApiKey = process.env.HYPIXELAPIKEY; -const fetch = require("axios"); -const { color, hypixelGuildID } = require("../config/options.json"); -const verify = require("../schemas/verifySchema.js"); -const { mongoose } = require("mongoose"); -const { - gm, - manager, - moderator, - beast, - member, - trialmember, - guildRole, - guildStaff, - defaultMember -} = require("../config/roles.json"); +const fetch = require('axios'); +const { color, hypixelGuildID } = require('../config/options.json'); +const verify = require('../schemas/verifySchema.js') +const {mongoose} = require('mongoose'); +const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); + module.exports = { - name: "forceverify", - description: "Force verify a user.", - type: "slash", + name: 'forceverify', + description: 'Force verify a user.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("forceverify") - .setDescription("Force verify a user.") - .addUserOption((option) => - option.setName("user").setDescription("The user to force verify.") - ) - .addStringOption((option) => - option.setName("ign").setDescription("The user's in-game name.") - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('forceverify') + .setDescription('Force verify a user.') + .addUserOption(option => + option + .setName('user') + .setDescription('The user to force verify.')) + .addStringOption(option => + option + .setName('ign') + .setDescription('The user\'s in-game name.')) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), + + async execute(interaction) { - async execute(interaction) { - await interaction.deferReply(); + await interaction.deferReply(); - const user1 = interaction.options.getUser("user"); - const user = interaction.guild.members.cache.get(user1.id); - const fullUsername = user1.username + "#" + user1.discriminator; - const ign = interaction.options.getString("ign"); - const mod = - interaction.user.username + "#" + interaction.user.discriminator; + const user1 = interaction.options.getUser('user'); + const user = interaction.guild.members.cache.get(user1.id); + const fullUsername = user1.username + "#" + user1.discriminator + const ign = interaction.options.getString('ign'); + const mod = interaction.user.username + "#" + interaction.user.discriminator - const mojang = "https://api.mojang.com/users/profiles/minecraft/"; - const slothPixel = "https://api.slothpixel.me/api/players/"; - const guildAPI = "https://api.slothpixel.me/api/guilds/"; - const minotar = "https://minotar.net/helm/"; - const embedColor = Number(color.replace("#", "0x")); + const mojang = "https://api.mojang.com/users/profiles/minecraft/" + const slothPixel = "https://api.slothpixel.me/api/players/"; + const guildAPI = "https://api.slothpixel.me/api/guilds/" + const minotar = "https://minotar.net/helm/"; + const embedColor = Number(color.replace("#", "0x")); - if (!user) { - interaction.editReply("Please provide a user to force verify."); - return; - } - - if (!ign) { - interaction.editReply("Please provide a player's IGN."); - return; - } - - const verifyData = await verify.findOne({ userID: user.id }); - - if (verifyData) { - interaction.editReply("That user is already verified."); - return; - } - - try { - await fetch(mojang + ign); - } catch (err) { - interaction.editReply("That player doesn't exist. [Mojang]"); - return; - } - - try { - await fetch(slothPixel + ign); - } catch (err) { - interaction.editReply("That player doesn't exist. [Hypixel]"); - return; - } - - const userCheck = await fetch(mojang + ign); - const userUUID = userCheck.data.id; - - const hypixelCheck = await fetch(slothPixel + userUUID); - const head = minotar + ign; - - try { - const guildCheck = await fetch(guildAPI + userUUID); - var responseGuildID = guildCheck.data.id; - } catch (err) { - var responseGuildID = null; - } - - if (responseGuildID !== hypixelGuildID) { - await user.roles.add(defaultMember, "User was force verified by " + mod); - - await interaction.editReply({ - embeds: [ - { - title: interaction.guild.name, - description: - "You have successfully force verified `" + - fullUsername + - "` with the account `" + - hypixelCheck.data.username + - "`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - icon_url: interaction.guild.iconURL(), - text: interaction.guild.name + " | Developed by Taken#0002" - } - } - ] - }); - return; - } - - const guildCheck = await fetch(guildAPI + userUUID); - const GuildMembers = await guildCheck.data.members; - const guildRank = GuildMembers.find( - (member) => member.uuid === hypixelCheck.data.uuid - ).rank; - - if (guildRank === "Guild Master" && guildCheck.data.id === hypixelGuildID) { - await user.roles.add(gm, "User was force verified by " + mod); - await user.roles.add(guildRole, "User was force verified by " + mod); - await user.roles.add(guildStaff, "User was force verified by " + mod); - } - - if (guildRank === "Manager" && guildCheck.data.id === hypixelGuildID) { - await user.roles.add(manager, "User was force verified by " + mod); - await user.roles.add(guildRole, "User was force verified by " + mod); - await user.roles.add(guildStaff, "User was force verified by " + mod); - } - - if (guildRank === "Moderator" && guildCheck.data.id === hypixelGuildID) { - await user.roles.add(moderator, "User was force verified by " + mod); - await user.roles.add(guildRole, "User was force verified by " + mod); - await user.roles.add(guildStaff, "User was force verified by " + mod); - } - - if (guildRank === "Beast" && guildCheck.data.id === hypixelGuildID) { - await user.roles.add(beast, "User was force verified by " + mod); - await user.roles.add(guildRole, "User was force verified by " + mod); - } - - if (guildRank === "Member" && guildCheck.data.id === hypixelGuildID) { - await user.roles.add(member, "User was force verified by " + mod); - await user.roles.add(guildRole, "User was force verified by " + mod); - } - - if (guildRank === "Trial Member" && guildCheck.data.id === hypixelGuildID) { - await user.roles.add(trialmember, "User was force verified by " + mod); - await user.roles.add(guildRole, "User was force verified by " + mod); - } - - await user.roles.add(defaultMember, "User was force verified by " + mod); - - const newVerify = new verify({ - _id: new mongoose.Types.ObjectId(), - userID: user.id, - uuid: userUUID - }); - - await newVerify.save(); - - await interaction.editReply({ - embeds: [ - { - title: interaction.guild.name, - description: - "You have successfully force verified `" + - fullUsername + - "` with the account `" + - hypixelCheck.data.username + - "`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - icon_url: interaction.guild.iconURL(), - text: interaction.guild.name + " | Developed by Taken#0002" - } + if (!user) { + interaction.editReply('Please provide a user to force verify.') + return } - ] - }); - } -}; + + if (!ign) { + interaction.editReply('Please provide a player\'s IGN.') + return + } + + const verifyData = await verify.findOne({ userID: user.id }) + + if (verifyData) { + interaction.editReply('That user is already verified.') + return + } + + try { + await fetch(mojang + ign); + } catch (err) { + interaction.editReply('That player doesn\'t exist. [Mojang]') + return + } + + try { + await fetch(slothPixel + ign); + } catch (err) { + interaction.editReply('That player doesn\'t exist. [Hypixel]') + return + } + + const userCheck = await fetch(mojang + ign); + const userUUID = userCheck.data.id; + + const hypixelCheck = await fetch(slothPixel + userUUID); + const head = minotar + ign; + + try { + const guildCheck = await fetch(guildAPI + userUUID); + var responseGuildID = guildCheck.data.id; + } catch (err) { + var responseGuildID = null; + } + + if (responseGuildID !== hypixelGuildID) { + + await user.roles.add(defaultMember, "User was force verified by " + mod); + + await interaction.editReply({ + embeds: [{ + title: interaction.guild.name, + description: "You have successfully force verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + icon_url: interaction.guild.iconURL(), + text: interaction.guild.name + " | Developed by Taken#0002" + } + }] + }); + return + } + + const guildCheck = await fetch(guildAPI + userUUID); + const GuildMembers = await guildCheck.data.members; + const guildRank = GuildMembers.find(member => member.uuid === hypixelCheck.data.uuid).rank; + + if (guildRank === "Guild Master" && guildCheck.data.id === hypixelGuildID) { + await user.roles.add(gm, "User was force verified by " + mod); + await user.roles.add(guildRole, "User was force verified by " + mod) + await user.roles.add(guildStaff, "User was force verified by " + mod) + } + + if (guildRank === "Manager" && guildCheck.data.id === hypixelGuildID) { + await user.roles.add(manager, "User was force verified by " + mod); + await user.roles.add(guildRole, "User was force verified by " + mod) + await user.roles.add(guildStaff, "User was force verified by " + mod) + } + + if (guildRank === "Moderator" && guildCheck.data.id === hypixelGuildID) { + await user.roles.add(moderator, "User was force verified by " + mod); + await user.roles.add(guildRole, "User was force verified by " + mod) + await user.roles.add(guildStaff, "User was force verified by " + mod) + } + + if (guildRank === "Beast" && guildCheck.data.id === hypixelGuildID) { + await user.roles.add(beast, "User was force verified by " + mod); + await user.roles.add(guildRole, "User was force verified by " + mod) + } + + if (guildRank === "Member" && guildCheck.data.id === hypixelGuildID) { + await user.roles.add(member, "User was force verified by " + mod); + await user.roles.add(guildRole, "User was force verified by " + mod) + } + + if (guildRank === "Trial Member" && guildCheck.data.id === hypixelGuildID) { + await user.roles.add(trialmember, "User was force verified by " + mod); + await user.roles.add(guildRole, "User was force verified by " + mod) + } + + await user.roles.add(defaultMember, "User was force verified by " + mod); + + const newVerify = new verify({ + _id: new mongoose.Types.ObjectId(), + userID: user.id, + uuid: userUUID + }) + + await newVerify.save(); + + await interaction.editReply({ + embeds: [{ + title: interaction.guild.name, + description: "You have successfully force verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + icon_url: interaction.guild.iconURL(), + text: interaction.guild.name + " | Developed by Taken#0002" + } + }] + }); + + } +}; \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 90bc1c9..09dcdf6 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,54 +1,54 @@ -const { SlashCommandBuilder, ChannelType } = require("discord.js"); -const { color } = require("../config/options.json"); +const { SlashCommandBuilder, ChannelType } = require('discord.js'); +const { color } = require('../config/options.json'); module.exports = { - name: "help", - description: "Help command", - type: "slash", + name: 'help', + description: 'Help command', + type: 'slash', + + data: new SlashCommandBuilder() + .setName('help') + .setDescription('Help command') + .setDMPermission(true), - data: new SlashCommandBuilder() - .setName("help") - .setDescription("Help command") - .setDMPermission(true), + async execute(interaction) { - async execute(interaction) { - await interaction.deferReply({ ephemeral: true }); + await interaction.deferReply({ ephemeral: true }); - const embedColor = Number(color.replace("#", "0x")); + const embedColor = Number(color.replace('#', '0x')); - await interaction.editReply({ - embeds: [ - { - title: "Commands", - description: "List of commands", - fields: [ - { - name: "/check", - value: "Check the stats of a player" - }, - { - name: "/reqs", - value: "Check the requirements of the guild" - }, - { - name: "/update", - value: "Update's your roles" - }, - { - name: "/help", - value: "Shows this message" - } - ], - color: embedColor, - thumbnail: { - url: interaction.guild.iconURL({ dynamic: true }) - }, - footer: { - icon_url: interaction.guild.iconURL({ dynamic: true }), - text: interaction.guild.name + " | Developed by: @Taken#0001" - } - } - ] - }); - } -}; + await interaction.editReply({ + embeds: [{ + title: 'Commands', + description: "List of commands", + fields: [ + { + name: '/check', + value: 'Check the stats of a player' + }, + { + name: '/reqs', + value: 'Check the requirements of the guild' + }, + { + name: '/update', + value: 'Update\'s your roles' + }, + { + name: '/help', + value: 'Shows this message' + } + ], + color: embedColor, + thumbnail: { + url: interaction.guild.iconURL({ dynamic: true }) + }, + footer: { + icon_url: interaction.guild.iconURL({ dynamic: true }), + text: interaction.guild.name + ' | Developed by: @Taken#0001' + } + }] + }); + + } +}; \ No newline at end of file diff --git a/commands/reqs.js b/commands/reqs.js index 1f42aba..a0deece 100644 --- a/commands/reqs.js +++ b/commands/reqs.js @@ -1,63 +1,50 @@ -const { SlashCommandBuilder } = require("discord.js"); -const { color } = require("../config/options.json"); -const { - bwfdkr, - bwstars, - bwwins, - duelswins, - swstars -} = require("../config/reqs.json"); +const { SlashCommandBuilder } = require('discord.js'); +const { color } = require('../config/options.json'); +const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../config/reqs.json'); module.exports = { - name: "reqs", - description: "Displays the requirements for the guild.", - type: "slash", - data: new SlashCommandBuilder() - .setName("reqs") - .setDescription("Displays the requirements for the guild."), + name: 'reqs', + description: 'Displays the requirements for the guild.', + type: 'slash', + data: new SlashCommandBuilder() + .setName('reqs') + .setDescription('Displays the requirements for the guild.'), - async execute(interaction) { - await interaction.deferReply({ ephemeral: true }); + async execute(interaction) { - const embedColor = Number(color.replace("#", "0x")); + await interaction.deferReply({ ephemeral: true }); - await interaction.editReply({ - embeds: [ - { - title: "Requirements", - description: - "**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**", - color: embedColor, - thumbnail: { - url: interaction.guild.iconURL() - }, - fields: [ - { - name: "**Bedwars**", - value: - "**Stars:** `" + - bwstars.toString() + - "`\n**Wins:** `" + - bwwins.toString() + - "`\n**FKDR:** `" + - bwfdkr.toString() + - "`" - }, - { - name: "**Skywars**", - value: "**Stars:** `" + swstars.toString() + "`" - }, - { - name: "**Duels**", - value: "**Wins:** `" + duelswins.toString() + "`" - } - ], - footer: { - text: interaction.guild.name + " | Developed by: @Taken#0002", - icon_url: interaction.guild.iconURL() - } - } - ] - }); - } -}; + const embedColor = Number(color.replace("#", "0x")); + + await interaction.editReply({ + embeds: [{ + title: 'Requirements', + description: '**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**', + color: embedColor, + thumbnail: { + url: interaction.guild.iconURL() + }, + fields: [ + { + name: '**Bedwars**', + value: '**Stars:** `' + bwstars.toString() + + '`\n**Wins:** `' + bwwins.toString() + + '`\n**FKDR:** `' + bwfdkr.toString() + '`' + }, + { + name: '**Skywars**', + value: '**Stars:** `' + swstars.toString() + '`' + }, + { + name: '**Duels**', + value: '**Wins:** `' + duelswins.toString() + '`' + } + ], + footer: { + text: interaction.guild.name + ' | Developed by: @Taken#0002', + icon_url: interaction.guild.iconURL() + } + }] + }) + } +} \ No newline at end of file diff --git a/commands/send.js b/commands/send.js index 2bedb32..3a44581 100644 --- a/commands/send.js +++ b/commands/send.js @@ -1,62 +1,57 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { color } = require("../config/options.json"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { color } = require('../config/options.json'); module.exports = { - name: "send", - description: "Send a message to a channel.", - type: "slash", + name: 'send', + description: 'Send a message to a channel.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("send") - .setDescription("Send a message to a channel.") - .addStringOption((option) => - option.setName("message").setDescription("The message to send.") - ) - .addChannelOption((option) => - option - .setName("channel") - .setDescription("The channel to send the message to.") - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('send') + .setDescription('Send a message to a channel.') + .addStringOption(option => + option + .setName('message') + .setDescription('The message to send.')) + .addChannelOption(option => + option + .setName('channel') + .setDescription('The channel to send the message to.')) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), + + async execute(interaction) { - async execute(interaction) { - await interaction.deferReply({ ephemeral: true }); + await interaction.deferReply({ ephemeral: true }); - const message = interaction.options.getString("message"); - const channel = interaction.options.getChannel("channel"); - const embedColor = Number(color.replace("#", "0x")); + const message = interaction.options.getString('message'); + const channel = interaction.options.getChannel('channel'); + const embedColor = Number(color.replace("#", "0x")); - if (!message) { - interaction.editReply({ - content: "Please provide a message to send.", - ephemeral: true - }); - return; - } - - if (!channel) { - interaction.editReply({ - content: "Please provide a channel to send the message to.", - ephemeral: true - }); - return; - } - - channel.send({ - embeds: [ - { - title: interaction.guild.name, - description: message, - color: embedColor, - thumbnail: { - url: interaction.guild.iconURL({ dynamic: true }) - }, - footer: { - text: "Developed by @Taken#0002" - } + if (!message) { + interaction.editReply({ content: 'Please provide a message to send.', ephemeral: true }) + return } - ] - }); - } -}; + + if (!channel) { + interaction.editReply({ content: 'Please provide a channel to send the message to.', ephemeral: true }) + return + } + + channel.send({ + embeds: [ + { + title: interaction.guild.name, + description: message, + color: embedColor, + thumbnail: { + url: interaction.guild.iconURL({ dynamic: true }) + }, + footer: { + text: "Developed by @Taken#0002" + } + } + ] + }); + } +}; \ No newline at end of file diff --git a/commands/setnick.js b/commands/setnick.js index 49cd72c..4a8a74f 100644 --- a/commands/setnick.js +++ b/commands/setnick.js @@ -1,50 +1,39 @@ -const { - SlashCommandBuilder, - PermissionFlagsBits, - userMention -} = require("discord.js"); +const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js') module.exports = { - name: "setnick", - description: "Set your nickname", - type: "slash", + name: 'setnick', + description: 'Set your nickname', + type: 'slash', - data: new SlashCommandBuilder() - .setName("setnick") - .setDescription("Set your nickname") - .addUserOption((option) => - option - .setName("user") - .setDescription("The user to set the nickname for") - .setRequired(true) - ) - .addStringOption((option) => - option - .setName("nickname") - .setDescription("The nickname to set") - .setRequired(true) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('setnick') + .setDescription('Set your nickname') + .addUserOption(option => + option + .setName('user') + .setDescription('The user to set the nickname for') + .setRequired(true)) + .addStringOption(option => + option + .setName('nickname') + .setDescription('The nickname to set') + .setRequired(true)) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames) + .setDMPermission(false), - async execute(interaction) { - const user = interaction.options.getUser("user"); - const nickname = interaction.options.getString("nickname"); - const member = await interaction.guild.members.fetch(user.id); + async execute(interaction) { + + const user = interaction.options.getUser('user'); + const nickname = interaction.options.getString('nickname'); + const member = await interaction.guild.members.fetch(user.id); + + if (!member.manageable) { + return interaction.reply({ content: 'I cannot set the nickname for this user!', ephemeral: true }); + } + + await member.setNickname(nickname, `Set by ${interaction.user.tag}`); + + await interaction.reply({ content: "Set the nickname of " + userMention(member.id) + " to " + nickname, ephemeral: true }); - if (!member.manageable) { - return interaction.reply({ - content: "I cannot set the nickname for this user!", - ephemeral: true - }); } - - await member.setNickname(nickname, `Set by ${interaction.user.tag}`); - - await interaction.reply({ - content: - "Set the nickname of " + userMention(member.id) + " to " + nickname, - ephemeral: true - }); - } -}; +} \ No newline at end of file diff --git a/commands/slowmode.js b/commands/slowmode.js index 6e4ec21..0a8e5cd 100644 --- a/commands/slowmode.js +++ b/commands/slowmode.js @@ -1,64 +1,59 @@ -const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { color } = require("../config/options.json"); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { color } = require('../config/options.json'); module.exports = { - name: "slowmode", - description: "Set the slowmode of a channel.", - type: "slash", + name: 'slowmode', + description: 'Set the slowmode of a channel.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("slowmode") - .setDescription("Set the slowmode of a channel.") - .addIntegerOption((option) => - option - .setName("seconds") - .setDescription("The amount of seconds to set the slowmode to.") - ) - .addChannelOption((option) => - option - .setName("channel") - .setDescription("The channel to set the slowmode of.") - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('slowmode') + .setDescription('Set the slowmode of a channel.') + .addIntegerOption(option => + option + .setName('seconds') + .setDescription('The amount of seconds to set the slowmode to.')) + .addChannelOption(option => + option + .setName('channel') + .setDescription('The channel to set the slowmode of.')) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), - async execute(interaction) { - await interaction.deferReply({ ephermeral: true }); + async execute(interaction) { - const seconds = interaction.options.getInteger("seconds") ?? 5; - const channel = - interaction.options.getChannel("channel") ?? interaction.channel; - const embedColor = Number(color.replace("#", "0x")); + await interaction.deferReply({ ephermeral: true }); - if (seconds > 21600) { - await channel.setRateLimitPerUser(21600); - await interaction.editReply({ - embeds: [ - { - description: `Set the slowmode of ${channel} to 21600 seconds.`, - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by: @Taken#0001", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - } - ] - }); - return; - } + const seconds = interaction.options.getInteger('seconds') ?? 5 + const channel = interaction.options.getChannel('channel') ?? interaction.channel + const embedColor = Number(color.replace("#", "0x")); - await interaction.editReply({ - embeds: [ - { - description: `Set the slowmode of ${channel} to ${seconds} seconds.`, - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by: @Taken#0001", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } + if (seconds > 21600) { + await channel.setRateLimitPerUser(21600) + await interaction.editReply({ + embeds: [{ + description: `Set the slowmode of ${channel} to 21600 seconds.`, + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by: @Taken#0001", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return } - ] - }); - await channel.setRateLimitPerUser(seconds); - } -}; + + await interaction.editReply({ + embeds: [{ + description: `Set the slowmode of ${channel} to ${seconds} seconds.`, + color: embedColor, + footer: { + text: interaction.guild.name + " | Developed by: @Taken#0001", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + await channel.setRateLimitPerUser(seconds) + + } +} \ No newline at end of file diff --git a/commands/update.js b/commands/update.js index d96c11d..dc9025a 100644 --- a/commands/update.js +++ b/commands/update.js @@ -1,282 +1,262 @@ -const { SlashCommandBuilder } = require("discord.js"); -const env = require("dotenv").config(); +const { SlashCommandBuilder } = require('discord.js'); +const env = require('dotenv').config(); const hypixelApiKey = process.env.HYPIXELAPIKEY; -const fetch = require("axios"); -const verify = require("../schemas/verifySchema.js"); -const { color, hypixelGuildID } = require("../config/options.json"); -const { - gm, - manager, - moderator, - beast, - member, - trialmember, - guildRole, - guildStaff, - defaultMember -} = require("../config/roles.json"); +const fetch = require('axios'); +const verify = require('../schemas/verifySchema.js') +const { color, hypixelGuildID } = require('../config/options.json'); +const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); -const removeThese = [ - gm, - manager, - moderator, - beast, - member, - trialmember, - guildRole, - guildStaff -]; +const removeThese = [gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff]; module.exports = { - name: "update", - description: "Update your guild rank.", - type: "slash", + name: 'update', + description: 'Update your guild rank.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("update") - .setDescription("Update your guild rank.") - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('update') + .setDescription('Update your guild rank.') + .setDMPermission(false), - async execute(interaction) { - await interaction.deferReply(); + async execute(interaction) { - const user1 = interaction.user; - const user = interaction.guild.members.cache.get(user1.id); - const verifyData = await verify.findOne({ userID: user.id }); - const roleManage = user.roles; - - if (!verifyData) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } - - await interaction.editReply({ - embeds: [ - { - description: "Updated your roles to `Default Member`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + await interaction.deferReply(); + + const user1 = interaction.user; + const user = interaction.guild.members.cache.get(user1.id); + const verifyData = await verify.findOne({ userID: user.id }) + const roleManage = user.roles; + + if (!verifyData) { + + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - return; - } - const slothPixel = "https://api.slothpixel.me/api/players/"; - const guildAPI = "https://api.slothpixel.me/api/guilds/"; - const mojangAPI = "https://api.mojang.com/user/profile/"; - const minotar = "https://minotar.net/helm/"; + await interaction.editReply({ + embeds: [{ + description: "Updated your roles to `Default Member`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } - const userCheck = await fetch(mojangAPI + verifyData.uuid); - const hypixelCheck = await fetch(slothPixel + verifyData.uuid); + const slothPixel = "https://api.slothpixel.me/api/players/"; + const guildAPI = "https://api.slothpixel.me/api/guilds/" + const mojangAPI = "https://api.mojang.com/user/profile/" + const minotar = "https://minotar.net/helm/"; + + const userCheck = await fetch(mojangAPI + verifyData.uuid); + const hypixelCheck = await fetch(slothPixel + verifyData.uuid); - try { - const guildCheck = await fetch(guildAPI + verifyData.uuid); - var responseGuildID = guildCheck.data.id; - } catch (err) { - var responseGuildID = null; - } + try { + const guildCheck = await fetch(guildAPI + verifyData.uuid); + var responseGuildID = guildCheck.data.id; + } catch (err) { + var responseGuildID = null; + } - if (responseGuildID !== hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } + if (responseGuildID !== hypixelGuildID) { - await roleManage.add(defaultMember, "User used the update command"); - - await interaction.editReply({ - embeds: [ - { - description: "Updated your roles to `Default Member`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - return; - } - const guildCheck = await fetch(guildAPI + verifyData.uuid); - const head = minotar + userCheck.data.name; + await roleManage.add(defaultMember, "User used the update command") - const embedColor = Number(color.replace("#", "0x")); - const GuildMembers = guildCheck.data.members; - const guildRank = GuildMembers.find( - (member) => member.uuid === verifyData.uuid - ).rank; + await interaction.editReply({ + embeds: [{ + description: "Updated your roles to `Default Member`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } + + const guildCheck = await fetch(guildAPI + verifyData.uuid); + const head = minotar + userCheck.data.name; - if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } + const embedColor = Number(color.replace("#", "0x")); + const GuildMembers = guildCheck.data.members; + const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank; - await roleManage.add(guildRole, "User used the update command"); - await roleManage.add(guildStaff, "User used the update command"); - await roleManage.add(gm, "User used the update command"); - await roleManage.add(defaultMember, "User used the update command"); + if (guildRank === 'Guild Master' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: "Your rank has been updated to `Guild Master`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - } + + await roleManage.add(guildRole, "User used the update command") + await roleManage.add(guildStaff, "User used the update command") + await roleManage.add(gm, "User used the update command") + await roleManage.add(defaultMember, "User used the update command") - if (guildRank === "Manager" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } + + await interaction.editReply({ + embeds: [{ + description: "Your rank has been updated to `Guild Master`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + } - await roleManage.add(guildRole, "User used the update command"); - await roleManage.add(guildStaff, "User used the update command"); - await roleManage.add(manager, "User used the update command"); - await roleManage.add(defaultMember, "User used the update command"); + if (guildRank === 'Manager' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: "Your rank has been updated to `Manager`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - } + + await roleManage.add(guildRole, "User used the update command") + await roleManage.add(guildStaff, "User used the update command") + await roleManage.add(manager, "User used the update command") + await roleManage.add(defaultMember, "User used the update command") - if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } + + await interaction.editReply({ + embeds: [{ + description: "Your rank has been updated to `Manager`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + } - await roleManage.add(guildRole, "User used the update command"); - await roleManage.add(guildStaff, "User used the update command"); - await roleManage.add(moderator, "User used the update command"); - await roleManage.add(defaultMember, "User used the update command"); + if (guildRank === 'Moderator' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: "Your rank has been updated to `Moderator`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - } + + await roleManage.add(guildRole, "User used the update command") + await roleManage.add(guildStaff, "User used the update command") + await roleManage.add(moderator, "User used the update command") + await roleManage.add(defaultMember, "User used the update command") - if (guildRank === "Beast" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } + + await interaction.editReply({ + embeds: [{ + description: "Your rank has been updated to `Moderator`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) - await roleManage.add(guildRole, "User used the update command"); - await roleManage.add(beast, "User used the update command"); - await roleManage.add(defaultMember, "User used the update command"); + } - await interaction.editReply({ - embeds: [ - { - description: "Your rank has been updated to `Beast`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + if (guildRank === 'Beast' && responseGuildID === hypixelGuildID) { + + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - return; - } + + await roleManage.add(guildRole, "User used the update command") + await roleManage.add(beast, "User used the update command") + await roleManage.add(defaultMember, "User used the update command") - if (guildRank === "Member" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } + + await interaction.editReply({ + embeds: [{ + description: "Your rank has been updated to `Beast`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } - await roleManage.add(guildRole, "User used the update command"); - await roleManage.add(member, "User used the update command"); - await roleManage.add(defaultMember, "User used the update command"); + if (guildRank === 'Member' && responseGuildID === hypixelGuildID) { - await interaction.editReply({ - embeds: [ - { - description: "Your rank has been updated to `Member`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - return; - } - if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) { - for (let i = 0; i < removeThese.length; i++) { - await roleManage.remove(removeThese[i], "Auto role removal. (Update)"); - } + await roleManage.add(guildRole, "User used the update command") + await roleManage.add(member, "User used the update command") + await roleManage.add(defaultMember, "User used the update command") - await roleManage.add(guildRole, "User used the update command"); - await roleManage.add(trialmember, "User used the update command"); - await roleManage.add(defaultMember, "User used the update command"); + + await interaction.editReply({ + embeds: [{ + description: "Your rank has been updated to `Member`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } - await interaction.editReply({ - embeds: [ - { - description: "Your rank has been updated to `Trial Member`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) + if (guildRank === 'Trial Member' && responseGuildID === hypixelGuildID) { + + for (let i = 0; i < removeThese.length; i++) { + await roleManage.remove(removeThese[i], "Auto role removal. (Update)") } - } - ] - }); - return; + + await roleManage.add(guildRole, "User used the update command") + await roleManage.add(trialmember, "User used the update command") + await roleManage.add(defaultMember, "User used the update command") + + + await interaction.editReply({ + embeds: [{ + description: "Your rank has been updated to `Trial Member`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + return + } + } - } -}; +}; \ No newline at end of file diff --git a/commands/verify.js b/commands/verify.js index fb3f617..50a84b7 100644 --- a/commands/verify.js +++ b/commands/verify.js @@ -1,191 +1,168 @@ -const { SlashCommandBuilder } = require("discord.js"); -const env = require("dotenv").config(); +const { SlashCommandBuilder } = require('discord.js'); +const env = require('dotenv').config(); const hypixelApiKey = process.env.HYPIXELAPIKEY; -const fetch = require("axios"); -const { color, hypixelGuildID } = require("../config/options.json"); -const verify = require("../schemas/verifySchema.js"); -const mongoose = require("mongoose"); -const { - gm, - manager, - moderator, - beast, - member, - trialmember, - guildRole, - guildStaff, - defaultMember -} = require("../config/roles.json"); +const fetch = require('axios'); +const { color, hypixelGuildID } = require('../config/options.json'); +const verify = require('../schemas/verifySchema.js') +const mongoose = require('mongoose'); +const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); + module.exports = { - name: "verify", - description: "Verify yourself as a member of the server.", - type: "slash", + name: 'verify', + description: 'Verify yourself as a member of the server.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("verify") - .setDescription("Verify yourself as a member of the server.") - .addStringOption((option) => - option.setName("ign").setDescription("Your in-game name.") - ) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('verify') + .setDescription('Verify yourself as a member of the server.') + .addStringOption(option => + option + .setName('ign') + .setDescription('Your in-game name.')) + .setDMPermission(false), - async execute(interaction) { - await interaction.deferReply(); + async execute(interaction) { - const user1 = interaction.user; - const user = await interaction.guild.members.fetch(user1.id); + await interaction.deferReply(); - const fullUsername = user.user.username + "#" + user.user.discriminator; - const ign = interaction.options.getString("ign"); - const mojang = "https://api.mojang.com/users/profiles/minecraft/"; - const slothPixel = "https://api.slothpixel.me/api/players/"; - const guildAPI = "https://api.slothpixel.me/api/guilds/"; - const minotar = "https://minotar.net/helm/"; - const embedColor = Number(color.replace("#", "0x")); + const user1 = interaction.user; + const user = await interaction.guild.members.fetch(user1.id); - const verifyData = await verify.findOne({ userID: user.id }); + const fullUsername = user.user.username + "#" + user.user.discriminator + const ign = interaction.options.getString('ign'); + const mojang = "https://api.mojang.com/users/profiles/minecraft/" + const slothPixel = "https://api.slothpixel.me/api/players/"; + const guildAPI = "https://api.slothpixel.me/api/guilds/" + const minotar = "https://minotar.net/helm/"; + const embedColor = Number(color.replace("#", "0x")); - if (verifyData) { - interaction.editReply("You are already verified."); - return; - } + const verifyData = await verify.findOne({ userID: user.id }) - if (!ign) { - interaction.editReply("Please provide a player's IGN."); - return; - } - - try { - await fetch(mojang + ign); - } catch (err) { - interaction.editReply("That player doesn't exist. [Mojang]"); - return; - } - - try { - await fetch(slothPixel + ign); - } catch (err) { - interaction.editReply("That player doesn't exist. [Hypixel]"); - return; - } - - const userCheck = await fetch(mojang + ign); - const userUUID = userCheck.data.id; - - const hypixelCheck = await fetch(slothPixel + userUUID); - const head = minotar + ign; - - if (hypixelCheck.data.links.DISCORD !== fullUsername) { - interaction.editReply( - "Your Discord tag does not match your in-game tag." - ); - return; - } - - try { - const guildCheck = await fetch(guildAPI + userUUID); - var responseGuildID = guildCheck.data.id; - } catch (err) { - var responseGuildID = null; - } - - if (responseGuildID !== hypixelGuildID) { - await user.roles.add(defaultMember, "Verification"); - - await interaction.editReply({ - embeds: [ - { - title: interaction.guild.name, - description: - "You have successfully verified `" + - fullUsername + - "` with the account `" + - hypixelCheck.data.username + - "`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - icon_url: interaction.guild.iconURL(), - text: interaction.guild.name + " | Developed by Taken#0002" - } - } - ] - }); - return; - } - - const guildCheck = await fetch(guildAPI + userUUID); - const GuildMembers = await guildCheck.data.members; - const guildRank = GuildMembers.find( - (member) => member.uuid === hypixelCheck.data.uuid - ).rank; - - if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) { - await user.roles.add(gm, "Verification"); - await user.roles.add(guildRole, "Verification"); - await user.roles.add(guildStaff, "Verification"); - } - - if (guildRank === "Manager" && responseGuildID === hypixelGuildID) { - await user.roles.add(manager, "Verification"); - await user.roles.add(guildRole, "Verification"); - await user.roles.add(guildStaff, "Verification"); - } - - if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) { - await user.roles.add(moderator, "Verification"); - await user.roles.add(guildRole, "Verification"); - await user.roles.add(guildStaff, "Verification"); - } - - if (guildRank === "Beast" && responseGuildID === hypixelGuildID) { - await user.roles.add(beast, "Verification"); - await user.roles.add(guildRole, "Verification"); - } - - if (guildRank === "Member" && responseGuildID === hypixelGuildID) { - await user.roles.add(member, "Verification"); - await user.roles.add(guildRole, "Verification"); - } - - if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) { - await user.roles.add(trialmember, "Verification"); - await user.roles.add(guildRole, "Verification"); - } - - await user.roles.add(defaultMember, "Verification"); - - const newVerify = new verify({ - _id: new mongoose.Types.ObjectId(), - userID: user.id, - uuid: userUUID - }); - - await newVerify.save(); - - await interaction.editReply({ - embeds: [ - { - title: interaction.guild.name, - description: - "You have successfully verified `" + - fullUsername + - "` with the account `" + - hypixelCheck.data.username + - "`.", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - icon_url: interaction.guild.iconURL(), - text: interaction.guild.name + " | Developed by Taken#0002" - } + if (verifyData) { + interaction.editReply('You are already verified.') + return } - ] - }); - } -}; + + if (!ign) { + interaction.editReply('Please provide a player\'s IGN.') + return + } + + try { + await fetch(mojang + ign); + } catch (err) { + interaction.editReply('That player doesn\'t exist. [Mojang]') + return + } + + try { + await fetch(slothPixel + ign); + } catch (err) { + interaction.editReply('That player doesn\'t exist. [Hypixel]') + return + } + + const userCheck = await fetch(mojang + ign); + const userUUID = userCheck.data.id; + + const hypixelCheck = await fetch(slothPixel + userUUID); + const head = minotar + ign; + + if (hypixelCheck.data.links.DISCORD !== fullUsername) { + interaction.editReply('Your Discord tag does not match your in-game tag.') + return + } + + try { + const guildCheck = await fetch(guildAPI + userUUID); + var responseGuildID = guildCheck.data.id; + } catch (err) { + var responseGuildID = null; + } + + if (responseGuildID !== hypixelGuildID) { + + await user.roles.add(defaultMember, "Verification") + + await interaction.editReply({ + embeds: [{ + title: interaction.guild.name, + description: "You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + icon_url: interaction.guild.iconURL(), + text: interaction.guild.name + " | Developed by Taken#0002" + } + }] + }); + return + } + + const guildCheck = await fetch(guildAPI + userUUID); + const GuildMembers = await guildCheck.data.members; + const guildRank = GuildMembers.find(member => member.uuid === hypixelCheck.data.uuid).rank; + + if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) { + await user.roles.add(gm, "Verification"); + await user.roles.add(guildRole, "Verification") + await user.roles.add(guildStaff, "Verification") + } + + if (guildRank === "Manager" && responseGuildID === hypixelGuildID) { + await user.roles.add(manager, "Verification"); + await user.roles.add(guildRole, "Verification") + await user.roles.add(guildStaff, "Verification") + } + + if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) { + await user.roles.add(moderator, "Verification"); + await user.roles.add(guildRole, "Verification") + await user.roles.add(guildStaff, "Verification") + } + + if (guildRank === "Beast" && responseGuildID === hypixelGuildID) { + await user.roles.add(beast, "Verification"); + await user.roles.add(guildRole, "Verification") + } + + if (guildRank === "Member" && responseGuildID === hypixelGuildID) { + await user.roles.add(member, "Verification"); + await user.roles.add(guildRole, "Verification") + } + + if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) { + await user.roles.add(trialmember, "Verification"); + await user.roles.add(guildRole, "Verification") + } + + await user.roles.add(defaultMember, "Verification") + + const newVerify = new verify({ + _id: new mongoose.Types.ObjectId(), + userID: user.id, + uuid: userUUID + }) + + await newVerify.save() + + await interaction.editReply({ + embeds: [{ + title: interaction.guild.name, + description: "You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + icon_url: interaction.guild.iconURL(), + text: interaction.guild.name + " | Developed by Taken#0002" + } + }] + }); + + } +}; \ No newline at end of file diff --git a/commands/whois.js b/commands/whois.js index b37f38b..e730a61 100644 --- a/commands/whois.js +++ b/commands/whois.js @@ -1,66 +1,58 @@ -const { - SlashCommandBuilder, - PermissionFlagsBits, - userMention -} = require("discord.js"); -const { color } = require("../config/options.json"); -const verify = require("../schemas/verifySchema.js"); -const fetch = require("axios"); +const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); +const { color } = require('../config/options.json'); +const verify = require('../schemas/verifySchema.js'); +const fetch = require('axios'); module.exports = { - name: "whois", - description: "Get's the ign of a user.", - type: "slash", + name: 'whois', + description: 'Get\'s the ign of a user.', + type: 'slash', - data: new SlashCommandBuilder() - .setName("whois") - .setDescription("Get's the ign of a user.") - .addUserOption((option) => - option - .setName("user") - .setDescription("The user to get the ign of.") - .setRequired(true) - ) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), + data: new SlashCommandBuilder() + .setName('whois') + .setDescription('Get\'s the ign of a user.') + .addUserOption(option => + option + .setName('user') + .setDescription('The user to get the ign of.') + .setRequired(true)) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), - async execute(interaction) { - await interaction.deferReply(); + async execute(interaction) { - const user = interaction.options.getUser("user"); - const embedColor = Number(color.replace("#", "0x")); - const mojang = "https://api.mojang.com/user/profile/"; - const minotar = "https://minotar.net/helm/"; + await interaction.deferReply(); - const verifiedUser = await verify.findOne({ userID: user.id }); + const user = interaction.options.getUser('user'); + const embedColor = Number(color.replace("#", "0x")); + const mojang = "https://api.mojang.com/user/profile/" + const minotar = "https://minotar.net/helm/"; - if (!verifiedUser) { - interaction.editReply({ - content: "This user has not verified their account." - }); - return; - } + const verifiedUser = await verify.findOne({ userID: user.id }); - const userCheck = await fetch(mojang + verifiedUser.uuid); - const ign = userCheck.data.name; - const head = minotar + ign; - - await interaction.editReply({ - embeds: [ - { - title: interaction.guild.name, - description: - "**User:** " + userMention(user.id) + "\n**IGN:** " + ign, - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by: @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } + if (!verifiedUser) { + interaction.editReply({ content: 'This user has not verified their account.' }); + return } - ] - }); - } -}; + + const userCheck = await fetch(mojang + verifiedUser.uuid); + const ign = userCheck.data.name; + const head = minotar + ign; + + await interaction.editReply({ + embeds: [{ + title: interaction.guild.name, + description: "**User:** " + userMention(user.id) + "\n**IGN:** " + ign, + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by: @Taken#0002", + icon_url: interaction.guild.iconURL({ dynamic: true }) + } + }] + }) + + } +}; \ No newline at end of file diff --git a/config/limitmessages.json b/config/limitmessages.json index bce1b22..67a62be 100644 --- a/config/limitmessages.json +++ b/config/limitmessages.json @@ -1,5 +1,5 @@ { - "largeM": "(256 characters max)", - "smallM": "(128 characters max)", - "ignM": "(16 characters max)" -} + "largeM": "(256 characters max)", + "smallM": "(128 characters max)", + "ignM": "(16 characters max)" +} \ No newline at end of file diff --git a/config/options.json b/config/options.json index a44a89a..f084d4f 100644 --- a/config/options.json +++ b/config/options.json @@ -1,7 +1,7 @@ { - "color": "#eeaadb", - "applicationsChannel": "776705352456470550", - "staffApplicationsChannel": "1039258641393520700", - "staffOtherChannel": "1082036748558803104", - "hypixelGuildID": "5a353a170cf2e529044f2935" -} + "color": "#eeaadb", + "applicationsChannel": "776705352456470550", + "staffApplicationsChannel": "1039258641393520700", + "staffOtherChannel": "1082036748558803104", + "hypixelGuildID": "5a353a170cf2e529044f2935" +} \ No newline at end of file diff --git a/config/questions.json b/config/questions.json index 5734773..d3be89a 100644 --- a/config/questions.json +++ b/config/questions.json @@ -1,30 +1,30 @@ { - "qu1": "What is your IGN?", - "qu2": "What is your hypixel Network Level?", - "qu3": "What stats are you submitting? (ex. BW lv 135 or SW lv 12 etc..)? Please provide us your best stats of the gamemode you main the most.", - "qu4": "Which talents make you a good member for Illegitimate? Tell us about your accomplishments, hobbies and ambitions both on Hypixel and in real life.", - "qu5": "Will you be able to make from 100k to 150k gexp x week?", - "qu6": "Tell us about: your age, what you expect to gain from Illegitimate, whether you play on other accounts; if you often will be inactive; your punishment history; etc… This section is all yours and we expect a longer answer.", - "qu7": "How did you find about us? (Yt, advertisement in lobbies, friend..)", - "qu8": "What is your time zone? (Example: GMT+1)", - "rq1": "What is your IGN?", - "rq2": "What is your hypixel Network Level?", - "rq3": "What stats are you submitting?", - "rq4": "Which talents make you a good member for Illegitimate?", - "rq5": "Will you be able to make from 100k to 150k gexp x week?", - "rq6": "Tell us about yourself.", - "rq7": "How did you find about us?", - "rq8": "What is your time zone?", - "sq1": "What is your IGN?", - "sq2": "How long have you been in the guild for?", - "sq3": "Have you been guild muted for any reason? (This includes mutes for staff disrespect, arguing with guild members, toxicity...)", - "sq4": "Are you an active guild member? (Keep in mind we will surely check your GEXP)", - "sq5": "Do you have any experience as a staff member (guild moderator) at all?", - "sq6": "Why should we choose you as a Guild Moderator? (Tell us what would you do for the guild, how are you gonna help us grow the community, how many hours per day are you willing to spend doing the stuff as moderator for the guild etc..", - "rsq1": "What is your IGN?", - "rsq2": "How long have you been in the guild for?", - "rsq3": "Have you been guild muted for any reason?", - "rsq4": "Are you an active guild member?", - "rsq5": "Do you have any experience as a staff member (guild moderator) at all?", - "rsq6": "Why should we choose you as a Guild Moderator?" -} + "qu1": "What is your IGN?", + "qu2": "What is your hypixel Network Level?", + "qu3": "What stats are you submitting? (ex. BW lv 135 or SW lv 12 etc..)? Please provide us your best stats of the gamemode you main the most.", + "qu4": "Which talents make you a good member for Illegitimate? Tell us about your accomplishments, hobbies and ambitions both on Hypixel and in real life.", + "qu5": "Will you be able to make from 100k to 150k gexp x week?", + "qu6": "Tell us about: your age, what you expect to gain from Illegitimate, whether you play on other accounts; if you often will be inactive; your punishment history; etc… This section is all yours and we expect a longer answer.", + "qu7": "How did you find about us? (Yt, advertisement in lobbies, friend..)", + "qu8": "What is your time zone? (Example: GMT+1)", + "rq1": "What is your IGN?", + "rq2": "What is your hypixel Network Level?", + "rq3": "What stats are you submitting?", + "rq4": "Which talents make you a good member for Illegitimate?", + "rq5": "Will you be able to make from 100k to 150k gexp x week?", + "rq6": "Tell us about yourself.", + "rq7": "How did you find about us?", + "rq8": "What is your time zone?", + "sq1": "What is your IGN?", + "sq2": "How long have you been in the guild for?", + "sq3": "Have you been guild muted for any reason? (This includes mutes for staff disrespect, arguing with guild members, toxicity...)", + "sq4": "Are you an active guild member? (Keep in mind we will surely check your GEXP)", + "sq5": "Do you have any experience as a staff member (guild moderator) at all?", + "sq6": "Why should we choose you as a Guild Moderator? (Tell us what would you do for the guild, how are you gonna help us grow the community, how many hours per day are you willing to spend doing the stuff as moderator for the guild etc..", + "rsq1": "What is your IGN?", + "rsq2": "How long have you been in the guild for?", + "rsq3": "Have you been guild muted for any reason?", + "rsq4": "Are you an active guild member?", + "rsq5": "Do you have any experience as a staff member (guild moderator) at all?", + "rsq6": "Why should we choose you as a Guild Moderator?" +} \ No newline at end of file diff --git a/config/reqs.json b/config/reqs.json index 0863358..8115f3c 100644 --- a/config/reqs.json +++ b/config/reqs.json @@ -1,7 +1,7 @@ { - "bwstars": 120, - "bwfdkr": 2, - "bwwins": 1200, - "swstars": 15, - "duelswins": 5000 -} + "bwstars": 120, + "bwfdkr": 2, + "bwwins": 1200, + "swstars": 15, + "duelswins": 5000 +} \ No newline at end of file diff --git a/config/roles.json b/config/roles.json index e96d3fc..70386e2 100644 --- a/config/roles.json +++ b/config/roles.json @@ -1,15 +1,15 @@ { - "gm": "815893218246787080", - "manager": "815880752683679824", - "moderator": "815880910019887134", - "beast": "815880942345519104", - "member": "815880984301404190", - "trialmember": "815877333532540938", - "guildStaff": "984584711227703336", - "guildRole": "1043224015722000514", - "waitingList": "1092543315053908120", - "defaultMember": "722386801930797056", - "admin": "528549814846095360", - "helper": "592371991294771226", - "muted": "594355088932339732" -} + "gm": "815893218246787080", + "manager": "815880752683679824", + "moderator": "815880910019887134", + "beast": "815880942345519104", + "member": "815880984301404190", + "trialmember": "815877333532540938", + "guildStaff": "984584711227703336", + "guildRole": "1043224015722000514", + "waitingList": "1092543315053908120", + "defaultMember": "722386801930797056", + "admin": "528549814846095360", + "helper": "592371991294771226", + "muted": "594355088932339732" +} \ No newline at end of file diff --git a/deploy-commands.js b/deploy-commands.js index 3fba81b..a79f479 100644 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -1,93 +1,86 @@ -const { REST, Routes } = require("discord.js"); -const env = require("dotenv").config(); +const { REST, Routes } = require('discord.js'); +const env = require('dotenv').config(); const token = process.env.TOKEN; const clientId = process.env.CLIENTID; -const fs = require("node:fs"); +const fs = require('node:fs'); const args = process.argv.slice(2); const arg = args[0]; if (!arg) { - console.log("Please specify a command to run!"); -} else if (arg === "--prod") { - const commands = []; - // Grab all the command files from the commands directory you created earlier - const commandFiles = fs - .readdirSync("./commands") - .filter((file) => file.endsWith(".js")); - const contentMenuCommands = fs - .readdirSync("./commands-contextmenu") - .filter((file) => file.endsWith(".js")); - - // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment - for (const file of commandFiles) { - const command = require(`./commands/${file}`); - commands.push(command.data.toJSON()); - } - - for (const file of contentMenuCommands) { - const command = require(`./commands-contextmenu/${file}`); - commands.push(command.data.toJSON()); - } - - // Construct and prepare an instance of the REST module - const rest = new REST({ version: "10" }).setToken(token); - - // and deploy your commands! - (async () => { - try { - console.log( - `Started refreshing ${commands.length} application (/) commands.` - ); - - // The put method is used to fully refresh all commands in the guild with the current set - const data = await rest.put(Routes.applicationCommands(clientId), { - body: commands - }); - - console.log( - `Successfully reloaded ${data.length} application (/) commands.` - ); - } catch (error) { - // And of course, make sure you catch and log any errors! - console.error(error); - } - })(); -} else if (arg === "--dev") { - const commands = []; - // Grab all the command files from the commands directory you created earlier - const commandFiles = fs - .readdirSync("./commands-contextmenu") - .filter((file) => file.endsWith(".js")); - - // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment - for (const file of commandFiles) { - const command = require(`./commands-contextmenu/${file}`); - commands.push(command.data.toJSON()); - } - - // Construct and prepare an instance of the REST module - const rest = new REST({ version: "10" }).setToken(token); - - // and deploy your commands! - (async () => { - try { - console.log( - `Started refreshing ${commands.length} application (/) commands.` - ); - - // The put method is used to fully refresh all commands in the guild with the current set - const data = await rest.put(Routes.applicationCommands(clientId), { - body: commands - }); - - console.log( - `Successfully reloaded ${data.length} application (/) commands.` - ); - } catch (error) { - // And of course, make sure you catch and log any errors! - console.error(error); - } - })(); -} else if (arg && arg !== "--prod" && arg !== "--dev") { - console.log("Invalid argument!"); + console.log('Please specify a command to run!'); } +else if (arg === '--prod') { + const commands = []; + // Grab all the command files from the commands directory you created earlier + const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); + const contentMenuCommands = fs.readdirSync('./commands-contextmenu').filter(file => file.endsWith('.js')); + + // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment + for (const file of commandFiles) { + const command = require(`./commands/${file}`); + commands.push(command.data.toJSON()); + } + + for (const file of contentMenuCommands) { + const command = require(`./commands-contextmenu/${file}`); + commands.push(command.data.toJSON()); + } + + // Construct and prepare an instance of the REST module + const rest = new REST({ version: '10' }).setToken(token); + + + // and deploy your commands! + (async () => { + try { + console.log(`Started refreshing ${commands.length} application (/) commands.`); + + // The put method is used to fully refresh all commands in the guild with the current set + const data = await rest.put( + Routes.applicationCommands(clientId), + { body: commands }, + ); + + console.log(`Successfully reloaded ${data.length} application (/) commands.`); + } catch (error) { + // And of course, make sure you catch and log any errors! + console.error(error); + } + })(); +} +else if (arg === '--dev') { + const commands = []; + // Grab all the command files from the commands directory you created earlier + const commandFiles = fs.readdirSync('./commands-contextmenu').filter(file => file.endsWith('.js')); + + // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment + for (const file of commandFiles) { + const command = require(`./commands-contextmenu/${file}`); + commands.push(command.data.toJSON()); + } + + // Construct and prepare an instance of the REST module + const rest = new REST({ version: '10' }).setToken(token); + + + // and deploy your commands! + (async () => { + try { + console.log(`Started refreshing ${commands.length} application (/) commands.`); + + // The put method is used to fully refresh all commands in the guild with the current set + const data = await rest.put( + Routes.applicationCommands(clientId), + { body: commands }, + ); + + console.log(`Successfully reloaded ${data.length} application (/) commands.`); + } catch (error) { + // And of course, make sure you catch and log any errors! + console.error(error); + } + })(); +} +else if (arg && arg !== '--prod' && arg !== '--dev') { + console.log('Invalid argument!'); +} \ No newline at end of file diff --git a/events/buttons/checkstats.js b/events/buttons/checkstats.js index 0480174..3dfb9cc 100644 --- a/events/buttons/checkstats.js +++ b/events/buttons/checkstats.js @@ -1,167 +1,127 @@ -const { color } = require("../../config/options.json"); -const fetch = require("axios"); -const guildapp = require("../../schemas/guildAppSchema.js"); -const { - bwfdkr, - bwstars, - bwwins, - duelswins, - swstars -} = require("../../config/reqs.json"); +const { color } = require('../../config/options.json'); +const fetch = require('axios'); +const guildapp = require('../../schemas/guildAppSchema.js'); +const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../../config/reqs.json'); module.exports = { - name: "checkstats", - description: "Check your stats.", - type: "button", + name: 'checkstats', + description: 'Check your stats.', + type: 'button', - async execute(interaction) { - await interaction.deferReply(); + async execute(interaction) { - const message = interaction.message; - const embed = message.embeds[0]; - const applicantId = embed.footer.text.split(" ")[1]; + await interaction.deferReply(); - const guildappdata = await guildapp.findOne({ userID: applicantId }); - const uuid = guildappdata.uuid; + const message = interaction.message; + const embed = message.embeds[0]; + const applicantId = embed.footer.text.split(" ")[1] - const mojang = "https://api.mojang.com/user/profile/"; - const slothPixel = "https://api.slothpixel.me/api/players/"; - const guildAPI = "https://api.slothpixel.me/api/guilds/"; - const minotar = "https://minotar.net/helm/"; - const embedColor = Number(color.replace("#", "0x")); + const guildappdata = await guildapp.findOne({ userID: applicantId }) + const uuid = guildappdata.uuid; + + const mojang = "https://api.mojang.com/user/profile/" + const slothPixel = "https://api.slothpixel.me/api/players/"; + const guildAPI = "https://api.slothpixel.me/api/guilds/" + const minotar = "https://minotar.net/helm/"; + const embedColor = Number(color.replace("#", "0x")); - const userCheck = await fetch(mojang + uuid); - const ign = userCheck.data.name; + const userCheck = await fetch(mojang + uuid); + const ign = userCheck.data.name; - try { - await fetch(slothPixel + uuid); - } catch (error) { - interaction.editReply("That player doesn't exist. [Hypixel]"); - return; - } - - const stats = await fetch(slothPixel + uuid); - const head = minotar + ign; - - const rank_formatted = stats.data.rank_formatted; - const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, ""); - - if (rank2 === "") { - var rank = ""; - } else { - var rank = rank2 + " "; - } - - try { - const guildCheck = await fetch(guildAPI + uuid); - var guildName = guildCheck.data.name; - } catch (error) { - var guildName = "None"; - } - - const hsbwstars = stats.data.stats.BedWars.level; - const hsbwfkdr = stats.data.stats.BedWars.final_k_d; - const hsbwwins = stats.data.stats.BedWars.wins; - const hsswstars = stats.data.stats.SkyWars.level; - const hsduelswins = stats.data.stats.Duels.general.wins; - - if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) { - var bwtitle = - " This player does not meet the BedWars requirements."; - } else { - var bwtitle = - " This player meets the BedWars requirements."; - } - - if (hsswstars < swstars) { - var swtitle = - " This player does not meet the SkyWars requirements."; - } else { - var swtitle = - " This player meets the SkyWars requirements."; - } - - if (hsduelswins < duelswins) { - var duelstitle = - " This player does not meet the Duels requirements."; - } else { - var duelstitle = - " This player meets the Duels requirements."; - } - - try { - const guildCheck = await fetch(guildAPI + userUUID); - const tag_formatted = guildCheck.data.tag_formatted; - const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, ""); - var guildTag = " " + guildTag2; - } catch (error) { - var guildTag = ""; - } - - await interaction.editReply({ - embeds: [ - { - title: rank + stats.data.username + guildTag, - description: - "**Network Level:** `" + - stats.data.level.toString() + - "`\n" + - "**Current Guild:** `" + - guildName + - "`", - color: embedColor, - thumbnail: { - url: head - }, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL() - }, - fields: [ - { - name: bwtitle, - value: - "**➺ Stars:** `" + - stats.data.stats.BedWars.level.toString() + - "`\n" + - "**➺ FKDR:** `" + - stats.data.stats.BedWars.final_k_d.toString() + - "`\n" + - "**➺ Wins:** `" + - stats.data.stats.BedWars.wins.toString() + - "`" - }, - { - name: swtitle, - value: - "**➺ Stars:** `" + - stats.data.stats.SkyWars.level.toFixed(2).toString() + - "`\n" + - "**➺ KDR:** `" + - stats.data.stats.SkyWars.kill_death_ratio.toString() + - "`\n" + - "**➺ Wins:** `" + - stats.data.stats.SkyWars.wins.toString() + - "`" - }, - { - name: duelstitle, - value: - "**➺ Wins:** `" + - stats.data.stats.Duels.general.wins.toString() + - "`\n" + - "**➺ KDR:** `" + - stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + - "`\n" + - "**➺ WLR:** `" + - stats.data.stats.Duels.general.win_loss_ratio - .toFixed(2) - .toString() + - "`" - } - ] + try { + await fetch(slothPixel + uuid); + } catch (error) { + interaction.editReply('That player doesn\'t exist. [Hypixel]') + return } - ] - }); - } -}; + + const stats = await fetch(slothPixel + uuid); + const head = minotar + ign; + + const rank_formatted = stats.data.rank_formatted + const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, "") + + if (rank2 === "") { + var rank = "" + } else { + var rank = rank2 + " " + } + + try { + const guildCheck = await fetch(guildAPI + uuid); + var guildName = guildCheck.data.name + } catch (error) { + var guildName = "None" + } + + const hsbwstars = stats.data.stats.BedWars.level + const hsbwfkdr = stats.data.stats.BedWars.final_k_d + const hsbwwins = stats.data.stats.BedWars.wins + const hsswstars = stats.data.stats.SkyWars.level + const hsduelswins = stats.data.stats.Duels.general.wins + + if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) { + var bwtitle = " This player does not meet the BedWars requirements." + } else { + var bwtitle = " This player meets the BedWars requirements." + } + + if (hsswstars < swstars) { + var swtitle = " This player does not meet the SkyWars requirements." + } else { + var swtitle = " This player meets the SkyWars requirements." + } + + if (hsduelswins < duelswins) { + var duelstitle = " This player does not meet the Duels requirements." + } else { + var duelstitle = " This player meets the Duels requirements." + } + + try { + const guildCheck = await fetch(guildAPI + userUUID); + const tag_formatted = guildCheck.data.tag_formatted + const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "") + var guildTag = " " + guildTag2 + } catch (error) { + var guildTag = "" + } + + await interaction.editReply({ + embeds: [{ + title: rank + stats.data.username + guildTag, + description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + + "**Current Guild:** `" + guildName + "`", + color: embedColor, + thumbnail: { + url: head + }, + footer: { + text: interaction.guild.name + " | Developed by @Taken#0002", + icon_url: interaction.guild.iconURL() + }, + fields: [ + { + name: bwtitle, + value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + "`\n" + + "**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + "`\n" + + "**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + "`" + }, + { + name: swtitle, + value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + "`\n" + + "**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" + + "**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`" + }, + { + name: duelstitle, + value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + "`\n" + + "**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + + "**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`" + } + ] + }] + + }) + } +}; \ No newline at end of file diff --git a/events/buttons/guilapply.js b/events/buttons/guilapply.js index 2042216..fb12e7f 100644 --- a/events/buttons/guilapply.js +++ b/events/buttons/guilapply.js @@ -1,631 +1,520 @@ -const { - ButtonBuilder, - ButtonStyle, - ActionRowBuilder, - EmbedBuilder -} = require("discord.js"); -const { color } = require("../../config/options.json"); -const { largeM, smallM, ignM } = require("../../config/limitmessages.json"); -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 fetch = require("axios"); +const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js'); +const { color } = require('../../config/options.json'); +const { largeM, smallM, ignM } = require('../../config/limitmessages.json') +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 fetch = require('axios'); module.exports = { - name: "guildapply", - description: "Guild application button.", - type: "button", + name: 'guildapply', + description: 'Guild application button.', + type: 'button', - async execute(interaction) { - const user = interaction.user; - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); + async execute(interaction) { - const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"; + const user = interaction.user; + const guild = interaction.guild; + const embedColor = Number(color.replace("#", "0x")); - const userRoles = guild.members.cache - .get(user.id) - .roles.cache.map((role) => role.id); + const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" - if (interaction.customId === "guildapply") { - await interaction.deferReply({ ephemeral: true }); + const userRoles = guild.members.cache.get(user.id).roles.cache.map(role => role.id); + + if (interaction.customId === 'guildapply') { + + await interaction.deferReply({ ephemeral: true }); - if (userRoles.includes(guildRole)) { - await interaction.editReply({ - content: "You are already a member of the guild.", - ephemeral: true - }); - return; - } - - const application = await guildapp.findOne({ userID: user.id }); - - if (application) { - await interaction.editReply({ - content: "You already have an application in progress.", - ephemeral: true - }); - return; - } - - const tooLong = new EmbedBuilder() - .setDescription("You took too long to respond.") - .setColor(embedColor); - const cancelled = new EmbedBuilder() - .setDescription("You have cancelled your application.") - .setColor(embedColor); - const attachments = new EmbedBuilder() - .setDescription( - "You have uploaded an attachment. Please do not upload images, videos, or GIFS." - ) - .setColor(embedColor); - - try { - await user.send({ - embeds: [ - { - title: "Guild Application", - description: - "Please answer the following questions to apply for the guild.\n" + - "If you wish to cancel your application, please press type `cancel` at any time.\n" + - "If you wish to proceed with your application, please type `yes`.\n\n" + - "**Do not upload images, videos, or GIFS.**\n" + - "You have a minute to respond to this message.", - color: embedColor + if (userRoles.includes(guildRole)) { + await interaction.editReply({ content: "You are already a member of the guild.", ephemeral: true }); + return } - ] - }); - } catch (error) { - await interaction.editReply({ - content: "Please enable your DMs.", - ephemeral: true - }); - return; - } - await interaction.editReply({ - content: "Please check your DMs.", - ephemeral: true - }); + const application = await guildapp.findOne({ userID: user.id }); - const input = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 - }); - if (input.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (input.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (input.first().content.toLowerCase() !== "yes") { - await user.send({ embeds: [cancelled] }); - return; - } + if (application) { + await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true }); + return + } + + const tooLong = new EmbedBuilder() + .setDescription("You took too long to respond.") + .setColor(embedColor) + const cancelled = new EmbedBuilder() + .setDescription("You have cancelled your application.") + .setColor(embedColor) + const attachments = new EmbedBuilder() + .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") + .setColor(embedColor) - // first question - const question1 = await user.send({ - embeds: [ - { - title: "**Question 1**", - description: - qu1 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - ignM + - "`", - color: embedColor, - footer: { - text: "You have 5 minutes to respond to this message." + try { + await user.send({ + embeds: [{ + title: 'Guild Application', + description: "Please answer the following questions to apply for the guild.\n" + + "If you wish to cancel your application, please press type `cancel` at any time.\n" + + "If you wish to proceed with your application, please type `yes`.\n\n" + + "**Do not upload images, videos, or GIFS.**\n" + + "You have a minute to respond to this message.", + color: embedColor, + }] + }) + } catch (error) { + await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true }); + return } - } - ] - }); - const answer1 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 5 - }); - if (answer1.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer1.first().content > 16) { - await user.send({ - embeds: [ - { - description: "Max character limit is 16.", - color: embedColor - } - ] - }); - return; - } - try { - await fetch(mojangAPI + answer1.first().content); - } catch (error) { - await user.send({ - embeds: [ - { - description: - "That is not a valid Minecraft username.\n" + - "Application cancelled.", - color: embedColor - } - ] - }); - return; - } - if (answer1.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer1.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer1_1 = answer1.first().content; - // second question - const question2 = await user.send({ - embeds: [ - { - title: "**Question 2**", - description: - qu2 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + - "`(8 characters max)`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." - } - } - ] - }); - const answer2 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer2.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer2.first().content.size > 8) { - await user.send({ - embeds: [ - { - description: "Max character limit is 8.", - color: embedColor - } - ] - }); - return; - } - if (answer2.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer2.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer2_1 = answer2.first().content; + await interaction.editReply({ content: "Please check your DMs.", ephemeral: true}) - // third question - const question3 = await user.send({ - embeds: [ - { - title: "**Question 3**", - description: - qu3 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - smallM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." - } - } - ] - }); - const answer3 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer3.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer3.first().content > 128) { - await user.send({ - embeds: [ - { - description: "Max character limit is 128.", - color: embedColor - } - ] - }); - } - if (answer3.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer3.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer3_1 = answer3.first().content; - // fourth question - const question4 = await user.send({ - embeds: [ - { - title: "**Question 4**", - description: - qu4 + - "\n\nPlease type your answer below or type `cancel` to cancel your application." + - " `(We expect a longer answer.)`\n`" + - largeM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." + const input = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 + }); + if (input.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return } - } - ] - }); - const answer4 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer4.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer4.first().content > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor + if (input.size === 0) { + await user.send({ embeds: [tooLong] }); + return } - ] - }); - } - if (answer4.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer4.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer4_1 = answer4.first().content; - - // fifth question - const question5 = await user.send({ - embeds: [ - { - title: "**Question 5**", - description: - qu5 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - smallM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." + if (input.first().content.toLowerCase() !== 'yes') { + await user.send({ embeds: [cancelled]} ); + return } - } - ] - }); - const answer5 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer5.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer5.first().content > 128) { - await user.send({ - embeds: [ - { - description: "Max character limit is 128.", - color: embedColor + + // first question + const question1 = await user.send({ + embeds: [{ + title : "**Question 1**", + description: qu1 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`", + color: embedColor, + footer:{ + text: "You have 5 minutes to respond to this message." + } + }] + }) + const answer1 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 5, + }); + if (answer1.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return } - ] - }); - } - if (answer5.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer5.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer5_1 = answer5.first().content; - - // sixth question - const question6 = await user.send({ - embeds: [ - { - title: "**Question 6**", - description: - qu6 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - largeM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." + if (answer1.first().content > 16) { + await user.send({ + embeds: [{ + description: "Max character limit is 16.", + color: embedColor + }] + }) + return } - } - ] - }); - const answer6 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer6.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer6.first().content > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor + try { + await fetch(mojangAPI + answer1.first().content) + } catch (error) { + await user.send({ + embeds: [{ + description: "That is not a valid Minecraft username.\n" + + "Application cancelled.", + color: embedColor + }] + }) + return } - ] - }); - } - if (answer6.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer6.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer6_1 = answer6.first().content; - - // seventh question - const question7 = await user.send({ - embeds: [ - { - title: "**Question 7**", - description: - qu7 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - smallM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." + if (answer1.size === 0) { + await user.send({ embeds: [tooLong] }) + return } - } - ] - }); - const answer7 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer7.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer7.first().content > 128) { - await user.send({ - embeds: [ - { - description: "Max character limit is 128.", - color: embedColor + if (answer1.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return } - ] - }); - } - if (answer7.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer7.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer7_1 = answer7.first().content; + const answer1_1 = answer1.first().content - // eighth question - const question8 = await user.send({ - embeds: [ - { - title: "**Question 8**", - description: - qu8 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + - "`(64 characters max)`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." + // second question + const question2 = await user.send({ + embeds: [{ + title : "**Question 2**", + description: qu2 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(8 characters max)`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer2 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer2.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return } - } - ] - }); - const answer8 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer8.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer8.first().content > 64) { - await user.send({ - embeds: [ - { - description: "Max character limit is 64.", - color: embedColor + if (answer2.first().content.size > 8) { + await user.send({ + embeds: [{ + description: "Max character limit is 8.", + color: embedColor + }] + }) + return } - ] - }); - } - if (answer8.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer8.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer8_1 = answer8.first().content; - - await user.send({ - embeds: [ - { - description: - "If you want to submit your application, type `yes` if not, type `no`", - color: embedColor - } - ] - }); - - const final = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 5 - }); - if (final.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (final.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (final.first().content.toLowerCase() !== "yes") { - await user.send({ embeds: [cancelled] }); - return; - } - - await user.send({ - embeds: [ - { - description: "Your application has been submitted!", - color: embedColor - } - ] - }); - - const userCheck = await fetch(mojangAPI + answer1_1); - const uuid = userCheck.data.id; - - 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", - color: embedColor, - thumbnail: { - url: user.avatarURL() - }, - fields: [ - { - name: rq1, - value: "```" + answer1_1 + "```" - }, - { - name: rq2, - value: "```" + answer2_1 + "```" - }, - { - name: rq3, - value: "```" + answer3_1 + "```" - }, - { - name: rq4, - value: "```" + answer4_1 + "```" - }, - { - name: rq5, - value: "```" + answer5_1 + "```" - }, - { - name: rq6, - value: "```" + answer6_1 + "```" - }, - { - name: rq7, - value: "```" + answer7_1 + "```" - }, - { - name: rq8, - value: "```" + answer8_1 + "```" - } - ], - footer: { - iconURL: guild.iconURL(), - text: "ID: " + user.id + if (answer2.size === 0) { + await user.send({ embeds: [tooLong] }) + return } - } - ], - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("guildapplicationaccept") - .setLabel("Accept") - .setStyle(ButtonStyle.Primary), - new ButtonBuilder() - .setCustomId("guildapplicationdeny") - .setLabel("Deny") - .setStyle(ButtonStyle.Danger), - new ButtonBuilder() - .setCustomId("checkstats") - .setLabel("Check Stats") - .setStyle(ButtonStyle.Secondary) - ) - ] - }); + if (answer2.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer2_1 = answer2.first().content + + // third question + const question3 = await user.send({ + embeds: [{ + title : "**Question 3**", + description: qu3 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer3 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer3.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer3.first().content > 128) { + await user.send({ + embeds: [{ + description: "Max character limit is 128.", + color: embedColor + }] + }) + } + if (answer3.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer3.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer3_1 = answer3.first().content + + // fourth question + const question4 = await user.send({ + embeds: [{ + title : "**Question 4**", + description: qu4 + "\n\nPlease type your answer below or type `cancel` to cancel your application." + + " `(We expect a longer answer.)`\n`" + largeM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer4 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer4.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer4.first().content > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + if (answer4.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer4.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer4_1 = answer4.first().content + + // fifth question + const question5 = await user.send({ + embeds: [{ + title : "**Question 5**", + description: qu5 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer5 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer5.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer5.first().content > 128) { + await user.send({ + embeds: [{ + description: "Max character limit is 128.", + color: embedColor + }] + }) + } + if (answer5.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer5.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer5_1 = answer5.first().content + + // sixth question + const question6 = await user.send({ + embeds: [{ + title : "**Question 6**", + description: qu6 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer6 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer6.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer6.first().content > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + if (answer6.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer6.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer6_1 = answer6.first().content + + // seventh question + const question7 = await user.send({ + embeds: [{ + title : "**Question 7**", + description: qu7 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer7 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer7.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer7.first().content > 128) { + await user.send({ + embeds: [{ + description: "Max character limit is 128.", + color: embedColor + }] + }) + } + if (answer7.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer7.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer7_1 = answer7.first().content + + // eighth question + const question8 = await user.send({ + embeds: [{ + title : "**Question 8**", + description: qu8 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(64 characters max)`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer8 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer8.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer8.first().content > 64) { + await user.send({ + embeds: [{ + description: "Max character limit is 64.", + color: embedColor + }] + }) + } + if (answer8.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer8.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer8_1 = answer8.first().content + + await user.send({ + embeds: [{ + description: "If you want to submit your application, type `yes` if not, type `no`", + color: embedColor + }] + }) + + const final = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 5 + }); + if (final.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (final.size === 0) { + await user.send({ embeds: [tooLong] }); + return + } + if (final.first().content.toLowerCase() !== 'yes') { + await user.send({ embeds: [cancelled]} ); + return + } + + await user.send({ + embeds: [{ + description: "Your application has been submitted!", + color: embedColor + }] + }) + + const userCheck = await fetch(mojangAPI + answer1_1) + const uuid = userCheck.data.id + + 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", + color: embedColor, + thumbnail: { + url: user.avatarURL() + }, + fields: [ + { + name: rq1, + value: "```" + answer1_1 + "```" + }, + { + name: rq2, + value: "```" + answer2_1 + "```" + }, + { + name: rq3, + value: "```" + answer3_1 + "```" + }, + { + name: rq4, + value: "```" + answer4_1 + "```" + }, + { + name: rq5, + value: "```" + answer5_1 + "```" + }, + { + name: rq6, + value: "```" + answer6_1 + "```" + }, + { + name: rq7, + value: "```" + answer7_1 + "```" + }, + { + name: rq8, + value: "```" + answer8_1 + "```" + } + ], + footer: { + iconURL: guild.iconURL(), + text: "ID: " + user.id + } + }], + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("guildapplicationaccept") + .setLabel("Accept") + .setStyle(ButtonStyle.Primary), + new ButtonBuilder() + .setCustomId("guildapplicationdeny") + .setLabel("Deny") + .setStyle(ButtonStyle.Danger), + new ButtonBuilder() + .setCustomId("checkstats") + .setLabel("Check Stats") + .setStyle(ButtonStyle.Secondary) + ) + ] + }); + + } } - } -}; +} \ No newline at end of file diff --git a/events/buttons/guildapplicationaccept.js b/events/buttons/guildapplicationaccept.js index 9000c10..14fc71a 100644 --- a/events/buttons/guildapplicationaccept.js +++ b/events/buttons/guildapplicationaccept.js @@ -1,77 +1,73 @@ -const { ActionRowBuilder, ButtonStyle, ButtonBuilder } = require("discord.js"); -const { color } = require("../../config/options.json"); -const guildapp = require("../../schemas/guildAppSchema.js"); -const { waitingList } = require("../../config/roles.json"); +const { ActionRowBuilder, ButtonStyle, ButtonBuilder } = require('discord.js'); +const { color } = require('../../config/options.json'); +const guildapp = require('../../schemas/guildAppSchema.js'); +const { waitingList } = require('../../config/roles.json'); module.exports = { - name: "guildapplicationaccept", - description: "Accept a guild application.", - type: "button", + name: 'guildapplicationaccept', + description: 'Accept a guild application.', + type: 'button', - async execute(interaction) { - await interaction.deferReply(); + async execute(interaction) { - const user = interaction.user; - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); + await interaction.deferReply(); - const message = interaction.message; - const embed = message.embeds[0]; - const applicantId = embed.footer.text.split(" ")[1]; + const user = interaction.user; + const guild = interaction.guild; + const embedColor = Number(color.replace("#", "0x")); - const applicant = await guild.members.fetch(applicantId); - const applicantUsername = - applicant.user.username + "#" + applicant.user.discriminator; + const message = interaction.message; + const embed = message.embeds[0]; + const applicantId = embed.footer.text.split(" ")[1] - await message.edit({ - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("guildapplicationaccept") - .setLabel("Accept") - .setStyle(ButtonStyle.Primary) - .setDisabled(true), - new ButtonBuilder() - .setCustomId("guildapplicationdeny") - .setLabel("Deny") - .setStyle(ButtonStyle.Danger) - .setDisabled(true), - new ButtonBuilder() - .setCustomId("checkstats") - .setLabel("Check Stats") - .setStyle(ButtonStyle.Secondary) - .setDisabled(true) - ) - ] - }); + const applicant = await guild.members.fetch(applicantId) + const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator; - await applicant.send({ - embeds: [ - { - description: `Your application for the Illegitimate guild has been accepted.`, - color: embedColor - } - ] - }); + await message.edit({ + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("guildapplicationaccept") + .setLabel("Accept") + .setStyle(ButtonStyle.Primary) + .setDisabled(true), + new ButtonBuilder() + .setCustomId("guildapplicationdeny") + .setLabel("Deny") + .setStyle(ButtonStyle.Danger) + .setDisabled(true), + new ButtonBuilder() + .setCustomId("checkstats") + .setLabel("Check Stats") + .setStyle(ButtonStyle.Secondary) + .setDisabled(true) + ) + ] + }); - await applicant.roles.add(waitingList); - await guildapp.findOneAndDelete({ userID: applicantId }); + await applicant.send({ + embeds: [{ + description: `Your application for the Illegitimate guild has been accepted.`, + color: embedColor + }] + }); - await interaction.editReply({ - embeds: [ - { - title: applicantUsername + " - Guild Application", - description: "Application has been accepted by <@" + user.id + ">.", - color: embedColor, - thumbnail: { - url: applicant.avatarURL() - }, - footer: { - iconURL: guild.iconURL(), - text: "ID: " + applicant.id - } - } - ] - }); - } -}; + await applicant.roles.add(waitingList); + await guildapp.findOneAndDelete({ userID: applicantId }); + + await interaction.editReply({ + embeds: [{ + title: applicantUsername + " - Guild Application", + description: "Application has been accepted by <@" + user.id + ">.", + color: embedColor, + thumbnail: { + url: applicant.avatarURL() + }, + footer: { + iconURL: guild.iconURL(), + text: "ID: " + applicant.id + } + }] + }); + } +}; \ No newline at end of file diff --git a/events/buttons/guildapplicationdeny.js b/events/buttons/guildapplicationdeny.js index 03e58e5..d90c16d 100644 --- a/events/buttons/guildapplicationdeny.js +++ b/events/buttons/guildapplicationdeny.js @@ -1,36 +1,32 @@ -const { - ModalBuilder, - ActionRowBuilder, - TextInputBuilder, - TextInputStyle -} = require("discord.js"); -const { color } = require("../../config/options.json"); +const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require('discord.js'); +const { color } = require('../../config/options.json'); module.exports = { - name: "guildapplicationdeny", - description: "Deny a guild application.", - type: "button", + name: 'guildapplicationdeny', + description: 'Deny a guild application.', + type: 'button', - async execute(interaction) { - const channel = interaction.channel; - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); + async execute(interaction) { - const message = interaction.message; + const channel = interaction.channel; + const guild = interaction.guild; + const embedColor = Number(color.replace("#", "0x")); - const modal = new ModalBuilder() - .setTitle("Deny Reason") - .setCustomId("denyreasonbox") - .setComponents( - new ActionRowBuilder().setComponents( - new TextInputBuilder() - .setLabel("Deny Reason") - .setCustomId("denyreason") - .setStyle(TextInputStyle.Paragraph) - .setPlaceholder("Enter a reason for denying the application") - .setRequired(false) - ) - ); - await interaction.showModal(modal); - } -}; + const message = interaction.message; + + const modal = new ModalBuilder() + .setTitle('Deny Reason') + .setCustomId('denyreasonbox') + .setComponents( + new ActionRowBuilder().setComponents( + new TextInputBuilder() + .setLabel('Deny Reason') + .setCustomId('denyreason') + .setStyle(TextInputStyle.Paragraph) + .setPlaceholder('Enter a reason for denying the application') + .setRequired(false) + ) + ) + await interaction.showModal(modal); + } +}; \ No newline at end of file diff --git a/events/buttons/staffapplicationaccept.js b/events/buttons/staffapplicationaccept.js index 37fd7f2..d8ae5e7 100644 --- a/events/buttons/staffapplicationaccept.js +++ b/events/buttons/staffapplicationaccept.js @@ -1,69 +1,66 @@ -const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); -const { color } = require("../../config/options.json"); -const staffapp = require("../../schemas/staffAppSchema.js"); +const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const { color } = require('../../config/options.json'); +const staffapp = require('../../schemas/staffAppSchema.js'); module.exports = { - name: "staffapplicationaccept", - description: "Accept a staff application.", - type: "button", + name: 'staffapplicationaccept', + description: 'Accept a staff application.', + type: 'button', - async execute(interaction) { - const user = interaction.user; - const channel = interaction.channel; - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); + async execute(interaction) { - const message = interaction.message; - const embed = message.embeds[0]; - const applicantId = embed.footer.text.split(" ")[1]; + const user = interaction.user; + const channel = interaction.channel; + const guild = interaction.guild; + const embedColor = Number(color.replace("#", "0x")); - const applicant = await guild.members.fetch(applicantId); - const applicantUsername = - applicant.user.username + "#" + applicant.user.discriminator; + const message = interaction.message; + const embed = message.embeds[0]; + const applicantId = embed.footer.text.split(" ")[1] - await applicant.send({ - embeds: [ - { - description: `Your application for the Illegitimate staff team has been accepted.`, - color: embedColor - } - ] - }); + const applicant = await guild.members.fetch(applicantId) + const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator; - await message.edit({ - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("staffapplicationaccept") - .setLabel("Accept") - .setStyle(ButtonStyle.Primary) - .setDisabled(true), - new ButtonBuilder() - .setCustomId("staffapplicationdeny") - .setLabel("Deny") - .setStyle(ButtonStyle.Danger) - .setDisabled(true) - ) - ] - }); + await applicant.send({ + embeds: [{ + description: `Your application for the Illegitimate staff team has been accepted.`, + color: embedColor + }] + }); - await staffapp.findOneAndDelete({ userId: applicantId }); + await message.edit({ + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("staffapplicationaccept") + .setLabel("Accept") + .setStyle(ButtonStyle.Primary) + .setDisabled(true), + new ButtonBuilder() + .setCustomId("staffapplicationdeny") + .setLabel("Deny") + .setStyle(ButtonStyle.Danger) + .setDisabled(true) + ) + ] + }); - await interaction.reply({ - embeds: [ - { - title: applicantUsername + " - Staff Application.", - description: "Application accepted by <@" + user.id + ">.", - color: embedColor, - thumbnail: { - url: applicant.avatarURL() - }, - footer: { - iconurl: guild.iconURL(), - text: "ID: " + applicantId - } - } - ] - }); - } -}; + await staffapp.findOneAndDelete({ userId: applicantId }); + + await interaction.reply({ + embeds: [{ + title: applicantUsername + " - Staff Application.", + description: "Application accepted by <@" + user.id + ">.", + color: embedColor, + thumbnail: { + url: applicant.avatarURL() + }, + footer: { + iconurl: guild.iconURL(), + text: "ID: " + applicantId + } + }] + }); + + } +} \ No newline at end of file diff --git a/events/buttons/staffapplicationdeny.js b/events/buttons/staffapplicationdeny.js index 7cae824..271d5ef 100644 --- a/events/buttons/staffapplicationdeny.js +++ b/events/buttons/staffapplicationdeny.js @@ -1,29 +1,25 @@ -const { - ModalBuilder, - ActionRowBuilder, - TextInputBuilder, - TextInputStyle -} = require("discord.js"); +const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require('discord.js'); module.exports = { - name: "staffapplicationdeny", - description: "Deny a guild application.", - type: "button", + name: 'staffapplicationdeny', + description: 'Deny a guild application.', + type: 'button', - async execute(interaction) { - const modal = new ModalBuilder() - .setTitle("Deny Reason") - .setCustomId("staffdenyreasonbox") - .setComponents( - new ActionRowBuilder().setComponents( - new TextInputBuilder() - .setLabel("Deny Reason") - .setCustomId("staffdenyreason") - .setStyle(TextInputStyle.Paragraph) - .setPlaceholder("Enter a reason for denying the application") - .setRequired(false) - ) - ); - await interaction.showModal(modal); - } -}; + async execute(interaction) { + + const modal = new ModalBuilder() + .setTitle('Deny Reason') + .setCustomId('staffdenyreasonbox') + .setComponents( + new ActionRowBuilder().setComponents( + new TextInputBuilder() + .setLabel('Deny Reason') + .setCustomId('staffdenyreason') + .setStyle(TextInputStyle.Paragraph) + .setPlaceholder('Enter a reason for denying the application') + .setRequired(false) + ) + ) + await interaction.showModal(modal); + } +}; \ No newline at end of file diff --git a/events/buttons/staffapply.js b/events/buttons/staffapply.js index 4a38701..5982156 100644 --- a/events/buttons/staffapply.js +++ b/events/buttons/staffapply.js @@ -1,523 +1,437 @@ -const { - ButtonBuilder, - ButtonStyle, - ActionRowBuilder, - EmbedBuilder -} = require("discord.js"); -const { color } = require("../../config/options.json"); -const { largeM, smallM, ignM } = require("../../config/limitmessages.json"); -const { staffApplicationsChannel } = require("../../config/options.json"); -const { sq1, sq2, sq3, sq4, sq5, sq6 } = require("../../config/questions.json"); -const { - rsq1, - rsq2, - rsq3, - rsq4, - rsq5, - rsq6 -} = require("../../config/questions.json"); -const { guildRole, guildStaff } = require("../../config/roles.json"); -const mongoose = require("mongoose"); -const staffapp = require("../../schemas/staffAppSchema.js"); -const fetch = require("axios"); +const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js'); +const { color } = require('../../config/options.json'); +const { largeM, smallM, ignM } = require('../../config/limitmessages.json') +const { staffApplicationsChannel } = require('../../config/options.json'); +const { sq1, sq2, sq3, sq4, sq5, sq6 } = require('../../config/questions.json'); +const { rsq1, rsq2, rsq3, rsq4, rsq5, rsq6 } = require('../../config/questions.json'); +const { guildRole, guildStaff } = require('../../config/roles.json') +const mongoose = require('mongoose'); +const staffapp = require('../../schemas/staffAppSchema.js'); +const fetch = require('axios'); module.exports = { - name: "staffapply", - description: "Apply for the staff team.", - type: "button", + name: 'staffapply', + description: 'Apply for the staff team.', + type: 'button', - async execute(interaction) { - const user = interaction.user; - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); - const userRoles = interaction.member.roles.cache; - const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"; + async execute(interaction) { - if (interaction.customId === "staffapply") { - await interaction.deferReply({ ephemeral: true }); + const user = interaction.user; + const guild = interaction.guild; + const embedColor = Number(color.replace("#", "0x")); + const userRoles = interaction.member.roles.cache; + const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" - if (!userRoles.has(guildRole)) { - await interaction.editReply({ - content: "You must be a member of the guild to apply for staff.", - ephemeral: true - }); - return; - } + if (interaction.customId === "staffapply") { - if (userRoles.has(guildStaff)) { - await interaction.editReply({ - content: "You are already a staff member.", - ephemeral: true - }); - return; - } + await interaction.deferReply({ ephemeral: true }); - const application = await staffapp.findOne({ userID: user.id }); - - if (application) { - await interaction.editReply({ - content: "You already have an application in progress.", - ephemeral: true - }); - return; - } - - const tooLong = new EmbedBuilder() - .setDescription("You took too long to respond.") - .setColor(embedColor); - const cancelled = new EmbedBuilder() - .setDescription("You have cancelled your application.") - .setColor(embedColor); - const attachments = new EmbedBuilder() - .setDescription( - "You have uploaded an attachment. Please do not upload images, videos, or GIFS." - ) - .setColor(embedColor); - - try { - await user.send({ - embeds: [ - { - title: "Staff Application", - description: - "Please answer the following questions to apply for staff.\n" + - "If you wish to cancel your application, please press type `cancel` at any time.\n" + - "If you wish to proceed with your application, please type `yes`.\n\n" + - "**Do not upload images, videos, or GIFS.**\n" + - "You have a minute to respond to this message.", - color: embedColor + if (!userRoles.has(guildRole)) { + await interaction.editReply({content: "You must be a member of the guild to apply for staff.", ephemeral: true}); + return } - ] - }); - } catch (error) { - await interaction.editReply({ - content: "Please enable your DMs.", - ephemeral: true - }); - return; - } - await interaction.editReply({ - content: "Please check your DMs.", - ephemeral: true - }); - - const input = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 - }); - if (input.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (input.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (input.first().content.toLowerCase() !== "yes") { - await user.send({ embeds: [cancelled] }); - return; - } - - // first question - const question1 = await user.send({ - embeds: [ - { - title: "**Question 1**", - description: - sq1 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - ignM + - "`", - color: embedColor, - footer: { - text: "You have 5 minutes to respond to this message." + if (userRoles.has(guildStaff)) { + await interaction.editReply({content: "You are already a staff member.", ephemeral: true}); + return } - } - ] - }); - const answer1 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 5 - }); - if (answer1.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer1.first().content > 16) { - await user.send({ - embeds: [ - { - description: "Max character limit is 16.", - color: embedColor - } - ] - }); - return; - } - try { - await fetch(mojangAPI + answer1.first().content); - } catch (error) { - await user.send({ - embeds: [ - { - description: - "That is not a valid Minecraft username.\n" + - "Application cancelled.", - color: embedColor - } - ] - }); - return; - } - if (answer1.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer1.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer1_1 = answer1.first().content; - // second question - const question2 = await user.send({ - embeds: [ - { - title: "**Question 2**", - description: - sq2 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + - "`(64 characters max)`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." + const application = await staffapp.findOne({ userID: user.id }); + + if (application) { + await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true }); + return } - } - ] - }); - const answer2 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer2.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer2.first().content > 64) { - await user.send({ - embeds: [ - { - description: "Max character limit is 64.", - color: embedColor - } - ] - }); - return; - } - if (answer2.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer2.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer2_1 = answer2.first().content; + + const tooLong = new EmbedBuilder() + .setDescription("You took too long to respond.") + .setColor(embedColor) + const cancelled = new EmbedBuilder() + .setDescription("You have cancelled your application.") + .setColor(embedColor) + const attachments = new EmbedBuilder() + .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") + .setColor(embedColor) + + try { + await user.send({ + embeds: [{ + title: 'Staff Application', + description: "Please answer the following questions to apply for staff.\n" + + "If you wish to cancel your application, please press type `cancel` at any time.\n" + + "If you wish to proceed with your application, please type `yes`.\n\n" + + "**Do not upload images, videos, or GIFS.**\n" + + "You have a minute to respond to this message.", + color: embedColor, + }] + }) + } catch (error) { + await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true }); + return + } + + await interaction.editReply({ content: "Please check your DMs.", ephemeral: true}) - // third question - const question3 = await user.send({ - embeds: [ - { - title: "**Question 3**", - description: - sq3 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - largeM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." - } - } - ] - }); - const answer3 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer3.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer3.first().content > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] - }); - } - if (answer3.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer3.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer3_1 = answer3.first().content; + const input = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 + }); + if (input.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (input.size === 0) { + await user.send({ embeds: [tooLong] }); + return + } + if (input.first().content.toLowerCase() !== 'yes') { + await user.send({ embeds: [cancelled]} ); + return + } + + // first question + const question1 = await user.send({ + embeds: [{ + title : "**Question 1**", + description: sq1 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`", + color: embedColor, + footer:{ + text: "You have 5 minutes to respond to this message." + } + }] + }) + const answer1 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 5, + }); + if (answer1.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer1.first().content > 16) { + await user.send({ + embeds: [{ + description: "Max character limit is 16.", + color: embedColor + }] + }) + return + } + try { + await fetch(mojangAPI + answer1.first().content) + } catch (error) { + await user.send({ + embeds: [{ + description: "That is not a valid Minecraft username.\n" + + "Application cancelled.", + color: embedColor + }] + }) + return + } + if (answer1.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer1.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer1_1 = answer1.first().content + + // second question + const question2 = await user.send({ + embeds: [{ + title : "**Question 2**", + description: sq2 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(64 characters max)`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer2 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer2.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer2.first().content > 64) { + await user.send({ + embeds: [{ + description: "Max character limit is 64.", + color: embedColor + }] + }) + return + } + if (answer2.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer2.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer2_1 = answer2.first().content + + // third question + const question3 = await user.send({ + embeds: [{ + title : "**Question 3**", + description: sq3 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer3 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer3.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer3.first().content > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + if (answer3.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer3.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer3_1 = answer3.first().content + + // fourth question + const question4 = await user.send({ + embeds: [{ + title : "**Question 4**", + description: sq4 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer4 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer4.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer4.first().content > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + if (answer4.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer4.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer4_1 = answer4.first().content + + // fifth question + const question5 = await user.send({ + embeds: [{ + title : "**Question 5**", + description: sq5 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer5 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer5.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer5.first().content > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + if (answer5.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer5.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer5_1 = answer5.first().content + + // sixth question + const question6 = await user.send({ + embeds: [{ + title : "**Question 6**", + description: sq6 + "\n\nPlease type your answer below or type `cancel` to cancel your application." + + "`(We expect a longer answer here)`\n`" + largeM + "`", + color: embedColor, + footer:{ + text: "You have 15 minutes to respond to this message." + } + }] + }) + const answer6 = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 15 + }); + if (answer6.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (answer6.first().content > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + if (answer6.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer6.first().content.toLowerCase() === 'cancel') { + await user.send({ embeds: [cancelled] }) + return + } + const answer6_1 = answer6.first().content - // fourth question - const question4 = await user.send({ - embeds: [ - { - title: "**Question 4**", - description: - sq4 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - largeM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." - } - } - ] - }); - const answer4 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer4.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer4.first().content > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] - }); - } - if (answer4.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer4.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer4_1 = answer4.first().content; + await user.send({ + embeds: [{ + description: "If you want to submit your application, type `yes` if not, type `no`", + color: embedColor + }] + }) + + const final = await user.dmChannel.awaitMessages({ + filter: m => m.author.id === user.id, + max: 1, + time: 1000 * 60 * 5 + }); + if (final.first().attachments.size > 0) { + await user.send({ embeds: [attachments] }); + return + } + if (final.size === 0) { + await user.send({ embeds: [tooLong] }); + return + } + if (final.first().content.toLowerCase() !== 'yes') { + await user.send({ embeds: [cancelled]} ); + return + } + + await user.send({ + embeds: [{ + description: "Your application has been submitted!", + color: embedColor + }] + }) - // fifth question - const question5 = await user.send({ - embeds: [ - { - title: "**Question 5**", - description: - sq5 + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - largeM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." - } - } - ] - }); - const answer5 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer5.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer5.first().content > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] - }); - } - if (answer5.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer5.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer5_1 = answer5.first().content; + const userCheck = await fetch(mojangAPI + answer1_1) + const uuid = userCheck.data.id - // sixth question - const question6 = await user.send({ - embeds: [ - { - title: "**Question 6**", - description: - sq6 + - "\n\nPlease type your answer below or type `cancel` to cancel your application." + - "`(We expect a longer answer here)`\n`" + - largeM + - "`", - color: embedColor, - footer: { - text: "You have 15 minutes to respond to this message." - } - } - ] - }); - const answer6 = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 15 - }); - if (answer6.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (answer6.first().content > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] - }); - } - if (answer6.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (answer6.first().content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }); - return; - } - const answer6_1 = answer6.first().content; + const newStaffApp = new staffapp({ + _id: new mongoose.Types.ObjectId(), + userID: user.id, + uuid: uuid, + }) - await user.send({ - embeds: [ - { - description: - "If you want to submit your application, type `yes` if not, type `no`", - color: embedColor - } - ] - }); + await newStaffApp.save() + await user.deleteDM(); - const final = await user.dmChannel.awaitMessages({ - filter: (m) => m.author.id === user.id, - max: 1, - time: 1000 * 60 * 5 - }); - if (final.first().attachments.size > 0) { - await user.send({ embeds: [attachments] }); - return; - } - if (final.size === 0) { - await user.send({ embeds: [tooLong] }); - return; - } - if (final.first().content.toLowerCase() !== "yes") { - await user.send({ embeds: [cancelled] }); - return; - } + const channel = guild.channels.cache.get(staffApplicationsChannel); - await user.send({ - embeds: [ - { - description: "Your application has been submitted!", - color: embedColor - } - ] - }); + await channel.send({ + embeds: [{ + title: user.username + "#" + user.discriminator + " - Staff Application", + color: embedColor, + thumbnail: { + url: user.avatarURL() + }, + fields: [ + { + name: rsq1, + value: "```" + answer1_1 + "```" + }, + { + name: rsq2, + value: "```" + answer2_1 + "```" + }, + { + name: rsq3, + value: "```" + answer3_1 + "```" + }, + { + name: rsq4, + value: "```" + answer4_1 + "```" + }, + { + name: rsq5, + value: "```" + answer5_1 + "```" + }, + { + name: rsq6, + value: "```" + answer6_1 + "```" + } - const userCheck = await fetch(mojangAPI + answer1_1); - const uuid = userCheck.data.id; - - const newStaffApp = new staffapp({ - _id: new mongoose.Types.ObjectId(), - userID: user.id, - uuid: uuid - }); - - await newStaffApp.save(); - await user.deleteDM(); - - const channel = guild.channels.cache.get(staffApplicationsChannel); - - await channel.send({ - embeds: [ - { - title: - user.username + "#" + user.discriminator + " - Staff Application", - color: embedColor, - thumbnail: { - url: user.avatarURL() - }, - fields: [ - { - name: rsq1, - value: "```" + answer1_1 + "```" - }, - { - name: rsq2, - value: "```" + answer2_1 + "```" - }, - { - name: rsq3, - value: "```" + answer3_1 + "```" - }, - { - name: rsq4, - value: "```" + answer4_1 + "```" - }, - { - name: rsq5, - value: "```" + answer5_1 + "```" - }, - { - name: rsq6, - value: "```" + answer6_1 + "```" - } - ], - footer: { - iconURL: guild.iconURL(), - text: "ID: " + user.id - } - } - ], - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("staffapplicationaccept") - .setLabel("Accept") - .setStyle(ButtonStyle.Primary), - new ButtonBuilder() - .setCustomId("staffapplicationdeny") - .setLabel("Deny") - .setStyle(ButtonStyle.Danger) - ) - ] - }); + ], + footer: { + iconURL: guild.iconURL(), + text: "ID: " + user.id + } + }], + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("staffapplicationaccept") + .setLabel("Accept") + .setStyle(ButtonStyle.Primary), + new ButtonBuilder() + .setCustomId("staffapplicationdeny") + .setLabel("Deny") + .setStyle(ButtonStyle.Danger) + ) + ] + } + ); + } } - } -}; +} \ No newline at end of file diff --git a/events/modals/denyreasonbox.js b/events/modals/denyreasonbox.js index 55ef558..a42ae7c 100644 --- a/events/modals/denyreasonbox.js +++ b/events/modals/denyreasonbox.js @@ -1,95 +1,78 @@ -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"); +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'); module.exports = { - name: "denyreasonbox", - description: "Deny reason box.", - type: "modal", + name: 'denyreasonbox', + description: 'Deny reason box.', + type: 'modal', - async execute(interaction) { - if (interaction.type !== InteractionType.ModalSubmit) return; - if (interaction.customId !== "denyreasonbox") return; + async execute(interaction) { + + if (interaction.type !== InteractionType.ModalSubmit) return; + if (interaction.customId !== "denyreasonbox") return; + + interaction.deferReply(); + + const guild = interaction.guild; - interaction.deferReply(); + const message = interaction.message; + const embed = message.embeds[0]; + const applicantId = embed.footer.text.split(" ")[1]; - const guild = interaction.guild; + const applicant = await guild.members.fetch(applicantId); + const reason = interaction.fields.fields.get('denyreason').value || "No reason provided"; + const embedColor = Number(color.replace("#", "0x")); + const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`); - const message = interaction.message; - const embed = message.embeds[0]; - const applicantId = embed.footer.text.split(" ")[1]; + await message.edit({ + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("guildapplicationaccept") + .setLabel("Accept") + .setStyle(ButtonStyle.Primary) + .setDisabled(true), + new ButtonBuilder() + .setCustomId("guildapplicationdeny") + .setLabel("Deny") + .setStyle(ButtonStyle.Danger) + .setDisabled(true), + new ButtonBuilder() + .setCustomId("checkstats") + .setLabel("Check Stats") + .setStyle(ButtonStyle.Secondary) + .setDisabled(true) + ) + ] + }); - const applicant = await guild.members.fetch(applicantId); - const reason = - interaction.fields.fields.get("denyreason").value || "No reason provided"; - const embedColor = Number(color.replace("#", "0x")); - const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`); + const dmMessage = new EmbedBuilder() + .setDescription("Your application for the Illegitimate guild has been denied\n" + + "**Reason:** `" + reason + "`") + .setColor(embedColor); - await message.edit({ - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("guildapplicationaccept") - .setLabel("Accept") - .setStyle(ButtonStyle.Primary) - .setDisabled(true), - new ButtonBuilder() - .setCustomId("guildapplicationdeny") - .setLabel("Deny") - .setStyle(ButtonStyle.Danger) - .setDisabled(true), - new ButtonBuilder() - .setCustomId("checkstats") - .setLabel("Check Stats") - .setStyle(ButtonStyle.Secondary) - .setDisabled(true) - ) - ] - }); + await applicant.send({ embeds: [dmMessage] }); - const dmMessage = new EmbedBuilder() - .setDescription( - "Your application for the Illegitimate guild has been denied\n" + - "**Reason:** `" + - reason + - "`" - ) - .setColor(embedColor); + await guildapp.findOneAndDelete({ userID: applicantId }); - await applicant.send({ embeds: [dmMessage] }); - - await guildapp.findOneAndDelete({ userID: applicantId }); - - await interaction.editReply({ - embeds: [ - { - title: "Application Denied", - description: - "The application has been denied by <@" + - interaction.user.id + - ">.\n" + - "**Reason:** `" + - reason + - "`", - color: embedColor, - thumbnail: { - url: applicant.avatarURL() - }, - footer: { - iconURL: guild.iconURL(), - text: "ID: " + applicant.id - } - } - ] - }); - } -}; + await interaction.editReply({ + embeds: [{ + title: "Application Denied", + description: "The application has been denied by <@" + interaction.user.id + ">.\n" + + "**Reason:** `" + reason + "`", + color: embedColor, + thumbnail: { + url: applicant.avatarURL() + }, + footer: { + iconURL: guild.iconURL(), + text: "ID: " + applicant.id + } + }], + }); + } +} \ No newline at end of file diff --git a/events/modals/staffdenyreasonbox.js b/events/modals/staffdenyreasonbox.js index e44ead9..6c94df6 100644 --- a/events/modals/staffdenyreasonbox.js +++ b/events/modals/staffdenyreasonbox.js @@ -1,90 +1,72 @@ -const { - InteractionType, - EmbedBuilder, - ActionRowBuilder, - ButtonBuilder, - ButtonStyle -} = require("discord.js"); -const { color } = require("../../config/options.json"); -const mongoose = require("mongoose"); -const staffapp = require("../../schemas/staffAppSchema.js"); -const fs = require("fs"); -const path = require("path"); +const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const { color } = require('../../config/options.json'); +const mongoose = require('mongoose'); +const staffapp = require('../../schemas/staffAppSchema.js'); +const fs = require('fs'); +const path = require('path'); module.exports = { - name: "staffdenyreasonbox", - description: "Deny reason box.", - type: "modal", + name: 'staffdenyreasonbox', + description: 'Deny reason box.', + type: 'modal', - async execute(interaction) { - if (interaction.type !== InteractionType.ModalSubmit) return; - if (interaction.customId !== "staffdenyreasonbox") return; + async execute(interaction) { + + if (interaction.type !== InteractionType.ModalSubmit) return; + if (interaction.customId !== "staffdenyreasonbox") return; + + interaction.deferReply(); + + const channel = interaction.channel; + const guild = interaction.guild; + const reason = interaction.fields.fields.get('staffdenyreason').value || "No reason provided"; + const embedColor = Number(color.replace("#", "0x")); - interaction.deferReply(); + const message = interaction.message; + const embed = message.embeds[0]; + const applicantId = embed.footer.text.split(" ")[1] + const applicant = await guild.members.fetch(applicantId) - const channel = interaction.channel; - const guild = interaction.guild; - const reason = - interaction.fields.fields.get("staffdenyreason").value || - "No reason provided"; - const embedColor = Number(color.replace("#", "0x")); + await message.edit({ + components: [ + new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId("staffapplicationaccept") + .setLabel("Accept") + .setStyle(ButtonStyle.Primary) + .setDisabled(true), + new ButtonBuilder() + .setCustomId("staffapplicationdeny") + .setLabel("Deny") + .setStyle(ButtonStyle.Danger) + .setDisabled(true), + ) + ] + }); - const message = interaction.message; - const embed = message.embeds[0]; - const applicantId = embed.footer.text.split(" ")[1]; - const applicant = await guild.members.fetch(applicantId); + const dmMessage = new EmbedBuilder() + .setDescription("Your application for the Illegitimate guild staff has been denied\n" + + "**Reason:** `" + reason + "`") + .setColor(embedColor); - await message.edit({ - components: [ - new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setCustomId("staffapplicationaccept") - .setLabel("Accept") - .setStyle(ButtonStyle.Primary) - .setDisabled(true), - new ButtonBuilder() - .setCustomId("staffapplicationdeny") - .setLabel("Deny") - .setStyle(ButtonStyle.Danger) - .setDisabled(true) - ) - ] - }); + await applicant.send({ embeds: [dmMessage] }); - const dmMessage = new EmbedBuilder() - .setDescription( - "Your application for the Illegitimate guild staff has been denied\n" + - "**Reason:** `" + - reason + - "`" - ) - .setColor(embedColor); + await staffapp.findOneAndDelete({ userID: applicantId }); - await applicant.send({ embeds: [dmMessage] }); - - await staffapp.findOneAndDelete({ userID: applicantId }); - - await interaction.editReply({ - embeds: [ - { - title: "Application Denied", - description: - "The application has been denied by <@" + - interaction.user.id + - ">.\n" + - "**Reason:** `" + - reason + - "`", - color: embedColor, - thumbnail: { - url: applicant.avatarURL() - }, - footer: { - iconURL: guild.iconURL(), - text: "ID: " + applicant.id - } - } - ] - }); - } -}; + await interaction.editReply({ + embeds: [{ + title: "Application Denied", + description: "The application has been denied by <@" + interaction.user.id + ">.\n" + + "**Reason:** `" + reason + "`", + color: embedColor, + thumbnail: { + url: applicant.avatarURL() + }, + footer: { + iconURL: guild.iconURL(), + text: "ID: " + applicant.id + } + }], + });; + } +} \ No newline at end of file diff --git a/index.js b/index.js index 30b0252..6456949 100644 --- a/index.js +++ b/index.js @@ -1,32 +1,25 @@ -const { - Client, - GatewayIntentBits, - Partials, - ActivityType, - Events, - Collection -} = require("discord.js"); -const env = require("dotenv").config(); +const { Client, GatewayIntentBits, Partials, ActivityType, Events, Collection } = require('discord.js'); +const env = require('dotenv').config(); const token = process.env.TOKEN; const mongoURI = process.env.MONGOURI; -const { connect } = require("mongoose"); -const path = require("path"); -const fs = require("fs"); +const { connect } = require('mongoose'); +const path = require('path'); +const fs = require('fs'); const client = new Client({ - intents: [ - GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMessages, - GatewayIntentBits.GuildMembers, - GatewayIntentBits.MessageContent, - GatewayIntentBits.DirectMessages - ], - partials: [ - Partials.GuildMember, - Partials.User, - Partials.Message, - Partials.Channel - ] + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.MessageContent, + GatewayIntentBits.DirectMessages + ], + partials: [ + Partials.GuildMember, + Partials.User, + Partials.Message, + Partials.Channel + ] }); client.commands = new Collection(); @@ -34,230 +27,207 @@ client.events = new Collection(); client.modals = new Collection(); //! commands -const cmdPath = path.join(__dirname, "commands"); -const cmdFiles = fs.readdirSync(cmdPath).filter((file) => file.endsWith(".js")); +const cmdPath = path.join(__dirname, 'commands'); +const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith('.js')); for (const file of cmdFiles) { - const filePath = path.join(cmdPath, file); - const cmd = require(filePath); - if ("data" in cmd && "execute" in cmd && cmd.type === "slash") { - client.commands.set(cmd.data.name, cmd); - } else { - console.log( - `[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.` - ); - } + const filePath = path.join(cmdPath, file); + const cmd = require(filePath); + + if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') { + client.commands.set(cmd.data.name, cmd); + } else { + console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`); + } } //! commands testing -const cmdTestPath = path.join(__dirname, "commands-testing"); -const cmdTestFiles = fs - .readdirSync(cmdTestPath) - .filter((file) => file.endsWith(".js")); +const cmdTestPath = path.join(__dirname, 'commands-testing'); +const cmdTestFiles = fs.readdirSync(cmdTestPath).filter(file => file.endsWith('.js')); for (const file of cmdTestFiles) { - const filePath = path.join(cmdTestPath, file); - const cmd = require(filePath); - if ("data" in cmd && "execute" in cmd && cmd.type === "slash") { - client.commands.set(cmd.data.name, cmd); - } else { - console.log( - `[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.` - ); - } + const filePath = path.join(cmdTestPath, file); + const cmd = require(filePath); + + if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') { + client.commands.set(cmd.data.name, cmd); + } else { + console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`); + } } //! command handler -client.on(Events.InteractionCreate, async (interaction) => { - if (!interaction.isChatInputCommand()) return; +client.on(Events.InteractionCreate, async interaction => { + if(!interaction.isChatInputCommand()) return; + + const command = interaction.client.commands.get(interaction.commandName); - const command = interaction.client.commands.get(interaction.commandName); + if (!command) { + console.error(`No command matching ${interaction.commandName} was found.`); + return; + } - if (!command) { - console.error(`No command matching ${interaction.commandName} was found.`); - return; - } - - try { - await command.execute(interaction); - } catch (error) { - console.error(error); - await interaction.reply({ - content: "There was an error while executing this command!", - ephemeral: true - }); - } + try { + await command.execute(interaction); + } catch (error) { + console.error(error); + await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }) + } }); //! commands -const contextMenuPath = path.join(__dirname, "commands-contextmenu"); -const contextMenuFiles = fs - .readdirSync(contextMenuPath) - .filter((file) => file.endsWith(".js")); +const contextMenuPath = path.join(__dirname, 'commands-contextmenu'); +const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith('.js')); for (const file of contextMenuFiles) { - const filePath = path.join(contextMenuPath, file); - const cmd = require(filePath); - if ("data" in cmd && "execute" in cmd && cmd.type === "contextmenu") { - client.commands.set(cmd.data.name, cmd); - } else { - console.log( - `[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.` - ); - } + const filePath = path.join(contextMenuPath, file); + const cmd = require(filePath); + + if ('data' in cmd && 'execute' in cmd && cmd.type === 'contextmenu') { + client.commands.set(cmd.data.name, cmd); + } else { + console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`); + } } //! context menu command handler -client.on(Events.InteractionCreate, async (interaction) => { - if (!interaction.isContextMenuCommand()) return; +client.on(Events.InteractionCreate, async interaction => { + if(!interaction.isContextMenuCommand()) return; + + const command = interaction.client.commands.get(interaction.commandName); - const command = interaction.client.commands.get(interaction.commandName); + if (!command) { + console.error(`No command matching ${interaction.commandName} was found.`); + return; + } - if (!command) { - console.error(`No command matching ${interaction.commandName} was found.`); - return; - } - - try { - await command.execute(interaction); - } catch (error) { - console.error(error); - await interaction.reply({ - content: "There was an error while executing this command!", - ephemeral: true - }); - } + try { + await command.execute(interaction); + } catch (error) { + console.error(error); + await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }) + } }); //! button events -const btnPath = path.join(__dirname, "events", "buttons"); -const btnFiles = fs.readdirSync(btnPath).filter((file) => file.endsWith(".js")); +const btnPath = path.join(__dirname, 'events', 'buttons'); +const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith('.js')); for (const file of btnFiles) { - const filePath = path.join(btnPath, file); - const btn = require(filePath); + + const filePath = path.join(btnPath, file); + const btn = require(filePath); - if ("name" in btn && "execute" in btn && btn.type === "button") { - client.events.set(btn.name, btn); - } else { - console.log( - `[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.` - ); - } + if ('name' in btn && 'execute' in btn && btn.type === 'button') { + client.events.set(btn.name, btn); + } else { + console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`); + } } //! button event handler -client.on(Events.InteractionCreate, async (event) => { - if (!event.isButton()) return; +client.on(Events.InteractionCreate, async event => { + if(!event.isButton()) return; - const event2 = event.client.events.get(event.customId); + const event2 = event.client.events.get(event.customId); - if (!event2) { - console.error(`No event matching ${event.customId} was found.`); - return; - } + if (!event2) { + console.error(`No event matching ${event.customId} was found.`); + return; + } - try { - await event2.execute(event); - } catch (error) { - console.error(error); - await event.reply({ - content: "There was an error while executing this event!", - ephemeral: true - }); - } -}); + try { + await event2.execute(event); + } catch (error) { + console.error(error); + await event.reply({ content: 'There was an error while executing this event!', ephemeral: true }) + } +}) //! modals -const modalPath = path.join(__dirname, "events", "modals"); -const modalFiles = fs - .readdirSync(modalPath) - .filter((file) => file.endsWith(".js")); +const modalPath = path.join(__dirname, 'events', 'modals'); +const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith('.js')); for (const file of modalFiles) { - const filePath = path.join(modalPath, file); - const modal = require(filePath); - if ("name" in modal && "execute" in modal && modal.type === "modal") { - client.on(Events.InteractionCreate, modal.execute); - } else { - console.log( - `[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.` - ); - } + const filePath = path.join(modalPath, file); + const modal = require (filePath); + + if ('name' in modal && 'execute' in modal && modal.type === 'modal') { + client.on(Events.InteractionCreate, modal.execute); + } else { + console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`); + } } client.on(Events.ClientReady, () => { - console.log("Logged in as " + client.user.tag + "!"); + console.log("Logged in as " + client.user.tag + "!"); }); // message events -const msgPath = path.join(__dirname, "events", "messages"); -const msgFiles = fs.readdirSync(msgPath).filter((file) => file.endsWith(".js")); +const msgPath = path.join(__dirname, 'events', 'messages'); +const msgFiles = fs.readdirSync(msgPath).filter(file => file.endsWith('.js')); for (const file of msgFiles) { - const filePath = path.join(msgPath, file); - const msg = require(filePath); - - if ("name" in msg && "execute" in msg && msg.type === "message") { - client.on(Events.MessageCreate, msg.execute); - } else { - console.log( - `[WARNING] The message at ${filePath} is missing a required "name", "execute" or "type" property.` - ); - } + + const filePath = path.join(msgPath, file); + const msg = require(filePath); + + if ('name' in msg && 'execute' in msg && msg.type === 'message') { + client.on(Events.MessageCreate, msg.execute); + } else { + console.log(`[WARNING] The message at ${filePath} is missing a required "name", "execute" or "type" property.`); + } } client.on(Events.ClientReady, () => { - client.user.setActivity({ - name: "over the Illegitimate Server", - type: ActivityType.Watching - }); - const activities = [ - { - name: "with Jone the idiot", - type: ActivityType.Playing - }, - { - name: "with Martina the bot", - type: ActivityType.Playing - }, - { - name: "urCryhard steal finals again", - type: ActivityType.Watching - }, - { - name: "with Perlcence the AI", - type: ActivityType.Playing - }, - { - name: "my creator Taken", - type: ActivityType.Watching - }, - { - name: "with ur mom in my bed", - type: ActivityType.Playing - }, - { - name: "over the Illegitimate Server", - type: ActivityType.Watching - } - ]; + client.user.setActivity({ name: "over the Illegitimate Server", type: ActivityType.Watching }); + + const activities = [ + { + name: "with Jone the idiot", + type: ActivityType.Playing + }, + { + name: "with Martina the bot", + type: ActivityType.Playing + }, + { + name: "urCryhard steal finals again", + type: ActivityType.Watching + }, + { + name: "with Perlcence the AI", + type: ActivityType.Playing + }, + { + name: "my creator Taken", + type: ActivityType.Watching + }, + { + name: "with ur mom in my bed", + type: ActivityType.Playing + }, + { + name: "over the Illegitimate Server", + type: ActivityType.Watching + } + ]; + + let i = 0; + setInterval(() => + client.user.setActivity(activities[i++ % activities.length]), 1000 * 60 * 30 + ) - let i = 0; - setInterval( - () => client.user.setActivity(activities[i++ % activities.length]), - 1000 * 60 * 30 - ); }); client.on(Events.ClientReady, () => { - client.user.setStatus("dnd"); + client.user.setStatus('dnd'); }); client.login(token); connect(mongoURI, {}).then(() => { - console.log("Connected to MongoDB"); -}); + console.log('Connected to MongoDB'); +}) \ No newline at end of file diff --git a/schemas/guildAppSchema.js b/schemas/guildAppSchema.js index aec5172..7069cc4 100644 --- a/schemas/guildAppSchema.js +++ b/schemas/guildAppSchema.js @@ -1,9 +1,9 @@ -const { Schema, model } = require("mongoose"); +const { Schema, model } = require('mongoose'); const guildAppSchema = new Schema({ - _id: Schema.Types.ObjectId, - userID: { type: String, required: true }, - uuid: { type: String, required: true } + _id: Schema.Types.ObjectId, + userID: { type: String, required: true }, + uuid: { type: String, required: true }, }); -module.exports = model("guildapp", guildAppSchema, "guildapp"); +module.exports = model('guildapp', guildAppSchema, 'guildapp'); \ No newline at end of file diff --git a/schemas/staffAppSchema.js b/schemas/staffAppSchema.js index 94477e0..94204a6 100644 --- a/schemas/staffAppSchema.js +++ b/schemas/staffAppSchema.js @@ -1,9 +1,9 @@ -const { Schema, model } = require("mongoose"); +const { Schema, model } = require('mongoose'); const staffAppSchema = new Schema({ - _id: Schema.Types.ObjectId, - userID: { type: String, required: true }, - uuid: { type: String, required: true } + _id: Schema.Types.ObjectId, + userID: { type: String, required: true }, + uuid: { type: String, required: true }, }); -module.exports = model("staffapp", staffAppSchema, "staffapp"); +module.exports = model('staffapp', staffAppSchema, 'staffapp'); \ No newline at end of file diff --git a/schemas/verifySchema.js b/schemas/verifySchema.js index 6154a63..995c5eb 100644 --- a/schemas/verifySchema.js +++ b/schemas/verifySchema.js @@ -1,9 +1,9 @@ -const { Schema, model } = require("mongoose"); +const { Schema, model } = require('mongoose'); const verifySchema = new Schema({ - _id: Schema.Types.ObjectId, - userID: { type: String, required: true }, - uuid: { type: String, required: true } + _id: Schema.Types.ObjectId, + userID: { type: String, required: true }, + uuid: { type: String, required: true }, }); -module.exports = model("verify", verifySchema, "verify"); +module.exports = model('verify', verifySchema, 'verify'); \ No newline at end of file diff --git a/utils/functions.js b/utils/functions.js index 93b3e6a..c7f73b2 100644 --- a/utils/functions.js +++ b/utils/functions.js @@ -1,26 +1,26 @@ const fetch = require("axios"); async function getuuid(ign) { - const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"; + const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" - try { - const user = await fetch(mojangAPI + ign); - return user.data.id; - } catch (error) { - return null; - } + try { + const user = await fetch(mojangAPI + ign) + return user.data.id; + } catch (error) { + return null; + } } async function getplayer(uuid) { - const slothPixel = "https://api.slothpixel.me/api/players/"; + const slothPixel = "https://api.slothpixel.me/api/players/"; - try { - const player = await fetch(slothPixel + uuid); - return player; - } catch (error) { - return null; - } + try { + const player = await fetch(slothPixel + uuid) + return player + } catch (error) { + return null; + } } -module.exports = getuuid; -module.exports = getplayer; +module.exports = getuuid +module.exports = getplayer \ No newline at end of file diff --git a/utils/mineflayer/limbo.js b/utils/mineflayer/limbo.js index 1647f8a..e7a73d3 100644 --- a/utils/mineflayer/limbo.js +++ b/utils/mineflayer/limbo.js @@ -1,11 +1,12 @@ module.exports = { - name: "limbo", - description: "Sends bot to limbo.", - type: "spawn", + name: 'limbo', + description: 'Sends bot to limbo.', + type: 'spawn', - async execute() { - const bot = require("../../index.js"); + async execute() { + const bot = require ('../../index.js'); - bot.chat("\u00a7"); - } -}; + bot.chat("\u00a7") + + } +}; \ No newline at end of file diff --git a/utils/mineflayer/logmessages.js b/utils/mineflayer/logmessages.js index 5b06a63..d67b307 100644 --- a/utils/mineflayer/logmessages.js +++ b/utils/mineflayer/logmessages.js @@ -1,27 +1,29 @@ -const client = require("../../index.js"); +const client = require('../../index.js'); module.exports = { - name: "Guild chat relay", - description: "Sends a message to the chat.", - type: "message", + name: 'Guild chat relay', + description: 'Sends a message to the chat.', + type: 'message', - async execute(jsonMsg) { - const gcchannel = "1092569207918575687"; + async execute(jsonMsg) { - const msg = jsonMsg.getText(); - const annoyingMessages = [ - "You are currently APPEARING OFFLINE", - "REMINDER: Your Online Status is currently set to Appear Offline", - "You have 1 unclaimed achievement reward!", - "Click here to view it!" - ]; + const gcchannel = "1092569207918575687" - if (annoyingMessages.includes(msg)) return; + const msg = jsonMsg.getText(); + const annoyingMessages = [ + "You are currently APPEARING OFFLINE", + "REMINDER: Your Online Status is currently set to Appear Offline", + "You have 1 unclaimed achievement reward!", + "Click here to view it!" + ] - console.log("[Chat message] " + msg); + if (annoyingMessages.includes(msg)) return; - const channel = client.guild.channels.cache.get(gcchannel); + console.log("[Chat message] " + msg); - channel.send(msg); - } -}; + const channel = client.guild.channels.cache.get(gcchannel); + + channel.send(msg); + + } +}; \ No newline at end of file diff --git a/utils/mineflayer/online.js b/utils/mineflayer/online.js index 32134ae..a7b5c0d 100644 --- a/utils/mineflayer/online.js +++ b/utils/mineflayer/online.js @@ -1,10 +1,10 @@ module.exports = { - name: "login", - description: "Logs the bot in.", - type: "login", + name: 'login', + description: 'Logs the bot in.', + type: 'login', - async execute() { - const bot = require("../../index.js"); - console.log("Logged in as " + bot.username + "!"); - } -}; + async execute() { + const bot = require ('../../index.js'); + console.log('Logged in as ' + bot.username + '!') + } +} \ No newline at end of file