From 5ce69eced32e2bd325082aadb5b157a416fd1cfb Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 20 Jan 2024 20:43:12 +0100 Subject: [PATCH] Fixed formatting on button files --- src/components/buttons/checkstats.ts | 179 +-- .../buttons/guildapplicationaccept.ts | 85 +- .../buttons/guildapplicationdeny.ts | 11 +- src/components/buttons/guildapply.ts | 1023 ++++++++--------- src/components/buttons/guildinactivitylog.ts | 248 ++-- .../buttons/staffapplicationaccept.ts | 38 +- .../buttons/staffapplicationdeny.ts | 11 +- src/components/buttons/staffapply.ts | 336 +++--- src/components/buttons/verify.ts | 7 +- src/components/buttons/waitingListUpdate.ts | 26 +- 10 files changed, 802 insertions(+), 1162 deletions(-) diff --git a/src/components/buttons/checkstats.ts b/src/components/buttons/checkstats.ts index c8d2708..0bf17d3 100644 --- a/src/components/buttons/checkstats.ts +++ b/src/components/buttons/checkstats.ts @@ -1,22 +1,7 @@ import { color, devMessage } from "config/options.json" import guildapp from "schemas/guildAppSchema" -import { - bwfkdr, - bwstars, - bwwins, - swstars, - swkdr, - duelswins, - duelswlr -} from "config/reqs.json" -import { - hypixelLevel, - bedwarsLevel, - skywarsLevel, - getPlayer, - getGuild, - getHeadURL -} from "utils/Hypixel" +import { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "config/reqs.json" +import { hypixelLevel, bedwarsLevel, skywarsLevel, getPlayer, getGuild, getHeadURL } from "utils/Hypixel" import { Button } from "interfaces" export = { @@ -36,13 +21,10 @@ export = { const player = await getPlayer(uuid) if (!player) { interaction.editReply({ - embeds: [ - { - description: - "That player hasn't played Hypixel before.", - color: embedColor - } - ] + embeds: [{ + description: "That player hasn't played Hypixel before.", + color: embedColor + }] }) return } @@ -97,149 +79,102 @@ export = { }) } else { if (player.stats.Bedwars) { - const hsbwexp = player.stats?.Bedwars?.Experience || 0 + const hsbwexp = player.stats.Bedwars?.Experience || 0 + const hsbwfk = player.stats.Bedwars?.final_kills_bedwars || 0 + const hsbwfd = player.stats.Bedwars?.final_deaths_bedwars || 0 + const hsbwwins = player.stats.Bedwars?.wins_bedwars || 0 const hsbwstars = bedwarsLevel(hsbwexp) - const hsbwfk = player.stats?.Bedwars?.final_kills_bedwars || 0 - const hsbwfd = player.stats?.Bedwars?.final_deaths_bedwars || 0 const hsbwfkdr = hsbwfk / hsbwfd || 0 - const hsbwwins = player.stats?.Bedwars?.wins_bedwars || 0 let bwtitle = "" - if ( - hsbwstars < bwstars || - hsbwfkdr < bwfkdr || - hsbwwins < bwwins - ) { - bwtitle = - " This player does not meet the BedWars requirements." + if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) { + bwtitle = " This player does not meet the BedWars requirements." } else { - bwtitle = - " This player meets the BedWars requirements." + bwtitle = " This player meets the BedWars requirements." } statsFields.push({ name: bwtitle, - value: - "**➺ Stars:** `" + - hsbwstars.toFixed(2).toString() + - " / " + - bwstars.toString() + - "`\n" + - "**➺ FKDR:** `" + - hsbwfkdr.toFixed(2).toString() + - " / " + - bwfkdr.toString() + - "`\n" + - "**➺ Wins:** `" + - hsbwwins.toString() + - " / " + - bwwins.toString() + - "`" + value: "**➺ Stars:** `" + hsbwstars.toFixed(2).toString() + + " / " + bwstars.toString() + "`\n" + + "**➺ FKDR:** `" + hsbwfkdr.toFixed(2).toString() + + " / " + bwfkdr.toString() + "`\n" + + "**➺ Wins:** `" + hsbwwins.toString() + + " / " + bwwins.toString() + "`" }) } if (player.stats.SkyWars) { - const hsswexp = player.stats?.SkyWars?.skywars_experience || 0 + const hsswexp = player.stats.SkyWars?.skywars_experience || 0 + const hsswkills = player.stats.SkyWars?.kills || 0 + const hsswdeaths = player.stats.SkyWars?.deaths || 0 + const hsswwins = player.stats.SkyWars?.wins || 0 const hsswstars = skywarsLevel(hsswexp) - const hsswkills = player.stats?.SkyWars?.kills || 0 - const hsswdeaths = player.stats?.SkyWars?.deaths || 0 const hsswkd = hsswkills / hsswdeaths - const hsswwins = player.stats?.SkyWars?.wins || 0 let swtitle = "" if (hsswstars < swstars || hsswkd < swkdr) { - swtitle = - " This player does not meet the SkyWars requirements." + swtitle = " This player does not meet the SkyWars requirements." } else { - swtitle = - " This player meets the SkyWars requirements." + swtitle = " This player meets the SkyWars requirements." } statsFields.push({ name: swtitle, - value: - "**➺ Stars:** `" + - hsswstars.toFixed(2).toString() + - " / " + - swstars.toString() + - "`\n" + - "**➺ KDR:** `" + - hsswkd.toFixed(2).toString() + - " / " + - swkdr.toString() + - "`\n" + - "**➺ Wins:** `" + - hsswwins.toString() + - "`" + value: "**➺ Stars:** `" + hsswstars.toFixed(2).toString() + + " / " + swstars.toString() + "`\n" + + "**➺ KDR:** `" + hsswkd.toFixed(2).toString() + + " / " + swkdr.toString() + "`\n" + + "**➺ Wins:** `" + hsswwins.toString() + "`" }) } if (player.stats.Duels) { - const hsduelskills = player.stats?.Duels?.kills || 0 - const hsduelsdeaths = player.stats?.Duels?.deaths || 0 + const hsduelskills = player.stats.Duels?.kills || 0 + const hsduelsdeaths = player.stats.Duels?.deaths || 0 + const hsduelswins = player.stats.Duels?.wins || 0 + const hsduelslosses = player.stats.Duels?.losses || 0 const hsduelskd = hsduelskills / hsduelsdeaths - const hsduelswins = player.stats?.Duels?.wins || 0 - const hsduelslosses = player.stats?.Duels?.losses || 0 const hsduelswlr = hsduelswins / hsduelslosses let duelstitle = "" if (hsduelswins < duelswins || hsduelswlr < duelswlr) { - duelstitle = - " This player does not meet the Duels requirements." + duelstitle = " This player does not meet the Duels requirements." } else { - duelstitle = - " This player meets the Duels requirements." + duelstitle = " This player meets the Duels requirements." } statsFields.push({ name: duelstitle, - value: - "**➺ Wins:** `" + - hsduelswins.toString() + - " / " + - duelswins.toString() + - "`\n" + - "**➺ WLR:** `" + - hsduelswlr.toFixed(2).toString() + - " / " + - duelswlr.toString() + - "`\n" + - "**➺ KDR:** `" + - hsduelskd.toFixed(2).toString() + - "`" + value: "**➺ Wins:** `" + hsduelswins.toString() + + " / " + duelswins.toString() + "`\n" + + "**➺ WLR:** `" + hsduelswlr.toFixed(2).toString() + + " / " + duelswlr.toString() + "`\n" + + "**➺ KDR:** `" + hsduelskd.toFixed(2).toString() + "`" }) } } // network level - const hypixelExp = player.networkExp || 0 + const hypixelExp = player?.networkExp || 0 const level = hypixelLevel(hypixelExp) await interaction.editReply({ - embeds: [ - { - title: rank + player.displayname + guildTag, - description: - "**Network Level:** `" + - level.toFixed(2).toString() + - "`\n" + - "**Current Guild:** `" + - guildName + - "`\n" + - "**Guild Rank:** `" + - guildRank + - "`", - color: embedColor, - thumbnail: { - url: head! - }, - footer: { - text: interaction.guild!.name + " | " + devMessage, - icon_url: interaction.guild!.iconURL() || undefined - }, - fields: statsFields - } - ] + embeds: [{ + title: rank + player.displayname + guildTag, + description: "**Network Level:** `" + level.toFixed(2).toString() + "`\n" + + "**Current Guild:** `" + guildName + "`\n" + + "**Guild Rank:** `" + guildRank + "`", + color: embedColor, + thumbnail: { + url: head! + }, + footer: { + text: interaction.guild!.name + " | " + devMessage, + icon_url: interaction.guild!.iconURL() || undefined + }, + fields: statsFields + }] }) } } as Button diff --git a/src/components/buttons/guildapplicationaccept.ts b/src/components/buttons/guildapplicationaccept.ts index 42cad9e..cc93bb9 100644 --- a/src/components/buttons/guildapplicationaccept.ts +++ b/src/components/buttons/guildapplicationaccept.ts @@ -1,15 +1,5 @@ -import { - ActionRowBuilder, - ButtonStyle, - ButtonBuilder, - TextChannel -} from "discord.js" -import { - color, - waitingListChannel, - waitingListMessage, - hypixelGuildID -} from "config/options.json" +import { ActionRowBuilder, ButtonStyle, ButtonBuilder, TextChannel } from "discord.js" +import { color, waitingListChannel, waitingListMessage, hypixelGuildID } from "config/options.json" import colorLog from "utils/functions/colors" import mongoose from "mongoose" import guildapp from "schemas/guildAppSchema" @@ -35,8 +25,7 @@ export = { const applicantIGN = embed.fields[0].value.replaceAll("`", "") const applicant = await guild.members.fetch(applicantId) - const applicantUsername = - applicant.user.username + "#" + applicant.user.discriminator + const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator await message.edit({ components: [ @@ -61,14 +50,11 @@ export = { }) await applicant.send({ - embeds: [ - { - description: - "Your application for the Illegitimate guild has been accepted.\n\n" + - "Make sure to leave your current guild so that we can invite you.", - color: embedColor - } - ] + embeds: [{ + description: "Your application for the Illegitimate guild has been accepted.\n\n" + + "Make sure to leave your current guild so that we can invite you.", + color: embedColor + }] }) const applicantEntry = await guildapp.findOne({ userID: applicantId }) @@ -89,28 +75,23 @@ export = { 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: { - icon_url: guild.iconURL() || undefined, - text: "ID: " + applicant.id - } + embeds: [{ + title: applicantUsername + " - Guild Application", + description: "Application has been accepted by <@" + user.id + ">.", + color: embedColor, + thumbnail: { + url: applicant.avatarURL() || "" + }, + footer: { + icon_url: guild.iconURL() || undefined, + text: "ID: " + applicant.id } - ] + }] }) if (process.env.NODE_ENV === "dev") return try { - const channel = guild.channels.cache.get( - waitingListChannel - ) as TextChannel + const channel = guild.channels.cache.get(waitingListChannel) as TextChannel const wlmessage = await channel!.messages.fetch(waitingListMessage) const wlembed = wlmessage.embeds[0] @@ -138,20 +119,18 @@ export = { } await wlmessage.edit({ - embeds: [ - { - title: wlembed.title!, - description: wlembed.description!, - color: wlembed.color!, - footer: { - text: "Last updated by " + user.username, - icon_url: user.avatarURL() || undefined - }, - thumbnail: wlembed.thumbnail!, - fields: fields, - timestamp: new Date().toISOString() - } - ] + embeds: [{ + title: wlembed.title!, + description: wlembed.description!, + color: wlembed.color!, + footer: { + text: "Last updated by " + user.username, + icon_url: user.avatarURL() || undefined + }, + thumbnail: wlembed.thumbnail!, + fields: fields, + timestamp: new Date().toISOString() + }] }) } catch (err) { console.log( diff --git a/src/components/buttons/guildapplicationdeny.ts b/src/components/buttons/guildapplicationdeny.ts index 5cc6ab4..5d55c21 100644 --- a/src/components/buttons/guildapplicationdeny.ts +++ b/src/components/buttons/guildapplicationdeny.ts @@ -1,9 +1,4 @@ -import { - ModalBuilder, - ActionRowBuilder, - TextInputBuilder, - TextInputStyle -} from "discord.js" +import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js" import { Button } from "interfaces" export = { @@ -20,9 +15,7 @@ export = { .setLabel("Deny Reason") .setCustomId("denyreason") .setStyle(TextInputStyle.Paragraph) - .setPlaceholder( - "Enter a reason for denying the application" - ) + .setPlaceholder("Enter a reason for denying the application") .setRequired(false) ) ) diff --git a/src/components/buttons/guildapply.ts b/src/components/buttons/guildapply.ts index 7a26084..d61d8b2 100644 --- a/src/components/buttons/guildapply.ts +++ b/src/components/buttons/guildapply.ts @@ -1,11 +1,4 @@ -import { - ButtonBuilder, - ButtonStyle, - ActionRowBuilder, - EmbedBuilder, - GuildMember, - TextChannel -} from "discord.js" +import { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder, GuildMember, TextChannel } from "discord.js" import { color } from "config/options.json" import { largeM, smallM, ignM } from "config/limitmessages.json" import { applicationsChannel } from "config/options.json" @@ -21,6 +14,7 @@ export = { description: "Guild application button.", async execute(interaction) { + await interaction.deferReply({ ephemeral: true }) const user = interaction.member as GuildMember const guild = interaction.guild! const embedColor = Number(color.replace("#", "0x")) @@ -35,575 +29,484 @@ export = { return guildQuestions[n - 1].r } - if (interaction.customId === "guildapply") { - await interaction.deferReply({ ephemeral: true }) + if (userRoles.includes(guildRole)) { + await interaction.editReply("You are already a member of the guild.") + return + } - if (userRoles.includes(guildRole)) { - await interaction.editReply( - "You are already a member of the guild." - ) - return - } + const application = await guildapp.findOne({ userID: user.user.id }) - const application = await guildapp.findOne({ userID: user.user.id }) + if (application) { + await interaction.editReply("You already have an application in progress.") + return + } - if (application) { - await interaction.editReply( - "You already have an application in progress." - ) - 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) - 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: - "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\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("Please enable your DMs.") - return - } - - await interaction.editReply("Please check your DMs.") - - const input = await user.dmChannel!.awaitMessages({ - filter: m => m.author.id === user.user.id, - max: 1, - time: 1000 * 60 - }) - if (input.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (input.first()!.content.toLowerCase() !== "yes") { - await user.send({ embeds: [cancelled] }) - return - } - if (input.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - - // first question + try { await user.send({ - embeds: [ - { - title: "**Question 1**", - description: - qu(1) + - "\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." - } - } - ] + embeds: [{ + title: "Guild Application", + description: "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" + + "**Do not upload images, videos, or GIFS.**\n" + + "You have a minute to respond to this message.", + color: embedColor + }] }) - const answer1 = await user.dmChannel!.awaitMessages({ - filter: m => m.author.id === user.user.id, - max: 1, - time: 1000 * 60 * 5 - }) - if (answer1.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer1.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer1.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer1.first()!.content.length > 16) { - await user.send({ - embeds: [ - { - description: "Max character limit is 16.", - color: embedColor - } - ] - }) - return - } - const uuid = await getUUID(answer1.first()!.content) - if (!uuid) { - await user.send({ - embeds: [ - { - description: - "That is not a valid Minecraft username.\n" + - "Application cancelled.", - color: embedColor - } - ] - }) - return - } - const answer1_1 = answer1.first()!.content + } catch (error) { + await interaction.editReply("Please enable your DMs.") + return + } - // second question + await interaction.editReply("Please check your DMs.") + + const input = await user.dmChannel!.awaitMessages({ + filter: m => m.author.id === user.user.id, + max: 1, + time: 1000 * 60 + }) + if (input.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (input.first()!.content.toLowerCase() !== "yes") { + await user.send({ embeds: [cancelled] }) + return + } + if (input.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + + // first question + await user.send({ + embeds: [{ + title: "**Question 1**", + description: qu(1) + "\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.user.id, + max: 1, + time: 1000 * 60 * 5 + }) + if (answer1.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer1.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer1.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer1.first()!.content.length > 16) { await user.send({ - embeds: [ - { - title: "**Question 2**", - description: - qu(2) + - "\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." - } - } - ] + embeds: [{ + description: "Max character limit is 16.", + color: embedColor + }] }) - const answer2 = await user.dmChannel!.awaitMessages({ - filter: m => m.author.id === user.user.id, - max: 1, - time: 1000 * 60 * 15 - }) - if (answer2.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer2.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer2.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer2.first()!.content.length > 8) { - await user.send({ - embeds: [ - { - description: "Max character limit is 8.", - color: embedColor - } - ] - }) - return - } - const answer2_1 = answer2.first()!.content - - // third question + return + } + const uuid = await getUUID(answer1.first()!.content) + if (!uuid) { await user.send({ - embeds: [ - { - title: "**Question 3**", - description: - qu(3) + - "\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." - } - } - ] + embeds: [{ + description: "That is not a valid Minecraft username.\n" + + "Application cancelled.", + color: embedColor + }] }) - const answer3 = await user.dmChannel!.awaitMessages({ - filter: m => m.author.id === user.user.id, - max: 1, - time: 1000 * 60 * 15 - }) - if (answer3.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer3.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer3.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer3.first()!.content.length > 128) { - await user.send({ - embeds: [ - { - description: "Max character limit is 128.", - color: embedColor - } - ] - }) - } - const answer3_1 = answer3.first()!.content + return + } + const answer1_1 = answer1.first()!.content - // fourth question + // second question + await user.send({ + embeds: [{ + title: "**Question 2**", + description: qu(2) + "\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.user.id, + max: 1, + time: 1000 * 60 * 15 + }) + if (answer2.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer2.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer2.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer2.first()!.content.length > 8) { await user.send({ - embeds: [ - { - title: "**Question 4**", - description: - qu(4) + - "\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." - } - } - ] + embeds: [{ + description: "Max character limit is 8.", + color: embedColor + }] }) - const answer4 = await user.dmChannel!.awaitMessages({ - filter: m => m.author.id === user.user.id, - max: 1, - time: 1000 * 60 * 15 - }) - if (answer4.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer4.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer4.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer4.first()!.content.length > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] - }) - } - const answer4_1 = answer4.first()!.content + return + } + const answer2_1 = answer2.first()!.content - // fifth question + // third question + await user.send({ + embeds: [{ + title: "**Question 3**", + description: qu(3) + "\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.user.id, + max: 1, + time: 1000 * 60 * 15 + }) + if (answer3.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer3.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer3.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer3.first()!.content.length > 128) { await user.send({ - embeds: [ - { - title: "**Question 5**", - description: - qu(5) + - "\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.user.id, - max: 1, - time: 1000 * 60 * 15 - }) - if (answer5.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer5.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer5.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer5.first()!.content.length > 128) { - await user.send({ - embeds: [ - { - description: "Max character limit is 128.", - color: embedColor - } - ] - }) - } - const answer5_1 = answer5.first()!.content - - // sixth question - await user.send({ - embeds: [ - { - title: "**Question 6**", - description: - qu(6) + - "\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.user.id, - max: 1, - time: 1000 * 60 * 15 - }) - if (answer6.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer6.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer6.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer6.first()!.content.length > 256) { - await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] - }) - } - const answer6_1 = answer6.first()!.content - - // seventh question - await user.send({ - embeds: [ - { - title: "**Question 7**", - description: - qu(7) + - "\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.user.id, - max: 1, - time: 1000 * 60 * 15 - }) - if (answer7.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer7.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer7.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer7.first()!.content.length > 128) { - await user.send({ - embeds: [ - { - description: "Max character limit is 128.", - color: embedColor - } - ] - }) - } - const answer7_1 = answer7!.first()!.content - - // eighth question - await user.send({ - embeds: [ - { - title: "**Question 8**", - description: - qu(8) + - "\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.user.id, - max: 1, - time: 1000 * 60 * 15 - }) - if (answer8.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (answer8.first()!.content.toLowerCase() === "cancel") { - await user.send({ embeds: [cancelled] }) - return - } - if (answer8.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - if (answer8.first()!.content.length > 64) { - await user.send({ - embeds: [ - { - description: "Max character limit is 64.", - color: embedColor - } - ] - }) - } - 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.user.id, - max: 1, - time: 1000 * 60 * 5 - }) - if (final.size === 0) { - await user.send({ embeds: [tooLong] }) - return - } - if (final.first()!.content.toLowerCase() !== "yes") { - await user.send({ embeds: [cancelled] }) - return - } - if (final.first()!.attachments.size > 0) { - await user.send({ embeds: [attachments] }) - return - } - - await user.send({ - embeds: [ - { - description: "Your application has been submitted!", - color: embedColor - } - ] - }) - - const newGuildApp = new guildapp({ - _id: new mongoose.Types.ObjectId(), - userID: user.user.id, - uuid: uuid - }) - - await newGuildApp.save() - - const channel = guild.channels.cache.get( - applicationsChannel - ) as TextChannel - await channel.send({ - embeds: [ - { - title: - user.user.username + - "#" + - user.user.discriminator + - " - Guild Application", - color: embedColor, - thumbnail: { - url: user.avatarURL() || "" - }, - fields: [ - { - name: rq(1), - value: "```" + answer1_1 + "```" - }, - { - name: rq(2), - value: "```" + answer2_1 + "```" - }, - { - name: rq(3), - value: "```" + answer3_1 + "```" - }, - { - name: rq(4), - value: "```" + answer4_1 + "```" - }, - { - name: rq(5), - value: "```" + answer5_1 + "```" - }, - { - name: rq(6), - value: "```" + answer6_1 + "```" - }, - { - name: rq(7), - value: "```" + answer7_1 + "```" - }, - { - name: rq(8), - value: "```" + answer8_1 + "```" - } - ], - footer: { - icon_url: guild.iconURL() || "", - text: "ID: " + user.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) - ) - ] + embeds: [{ + description: "Max character limit is 128.", + color: embedColor + }] }) } + const answer3_1 = answer3.first()!.content + + // fourth question + await user.send({ + embeds: [{ + title: "**Question 4**", + description: qu(4) + "\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.user.id, + max: 1, + time: 1000 * 60 * 15 + }) + if (answer4.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer4.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer4.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer4.first()!.content.length > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + const answer4_1 = answer4.first()!.content + + // fifth question + await user.send({ + embeds: [{ + title: "**Question 5**", + description: qu(5) + "\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.user.id, + max: 1, + time: 1000 * 60 * 15 + }) + if (answer5.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer5.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer5.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer5.first()!.content.length > 128) { + await user.send({ + embeds: [{ + description: "Max character limit is 128.", + color: embedColor + }] + }) + } + const answer5_1 = answer5.first()!.content + + // sixth question + await user.send({ + embeds: [{ + title: "**Question 6**", + description: qu(6) + "\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.user.id, + max: 1, + time: 1000 * 60 * 15 + }) + if (answer6.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer6.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer6.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer6.first()!.content.length > 256) { + await user.send({ + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] + }) + } + const answer6_1 = answer6.first()!.content + + // seventh question + await user.send({ + embeds: [{ + title: "**Question 7**", + description: qu(7) + "\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.user.id, + max: 1, + time: 1000 * 60 * 15 + }) + if (answer7.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer7.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer7.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer7.first()!.content.length > 128) { + await user.send({ + embeds: [{ + description: "Max character limit is 128.", + color: embedColor + }] + }) + } + const answer7_1 = answer7!.first()!.content + + // eighth question + await user.send({ + embeds: [{ + title: "**Question 8**", + description: qu(8) + "\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.user.id, + max: 1, + time: 1000 * 60 * 15 + }) + if (answer8.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (answer8.first()!.content.toLowerCase() === "cancel") { + await user.send({ embeds: [cancelled] }) + return + } + if (answer8.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + if (answer8.first()!.content.length > 64) { + await user.send({ + embeds: [{ + description: "Max character limit is 64.", + color: embedColor + }] + }) + } + 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.user.id, + max: 1, + time: 1000 * 60 * 5 + }) + if (final.size === 0) { + await user.send({ embeds: [tooLong] }) + return + } + if (final.first()!.content.toLowerCase() !== "yes") { + await user.send({ embeds: [cancelled] }) + return + } + if (final.first()!.attachments.size > 0) { + await user.send({ embeds: [attachments] }) + return + } + + await user.send({ + embeds: [{ + description: "Your application has been submitted!", + color: embedColor + }] + }) + + const newGuildApp = new guildapp({ + _id: new mongoose.Types.ObjectId(), + userID: user.user.id, + uuid: uuid + }) + + await newGuildApp.save() + + const channel = guild.channels.cache.get(applicationsChannel) as TextChannel + await channel.send({ + embeds: [{ + title: user.user.username + "#" + user.user.discriminator + " - Guild Application", + color: embedColor, + thumbnail: { + url: user.avatarURL() || "" + }, + fields: [ + { + name: rq(1), + value: "```" + answer1_1 + "```" + }, + { + name: rq(2), + value: "```" + answer2_1 + "```" + }, + { + name: rq(3), + value: "```" + answer3_1 + "```" + }, + { + name: rq(4), + value: "```" + answer4_1 + "```" + }, + { + name: rq(5), + value: "```" + answer5_1 + "```" + }, + { + name: rq(6), + value: "```" + answer6_1 + "```" + }, + { + name: rq(7), + value: "```" + answer7_1 + "```" + }, + { + name: rq(8), + value: "```" + answer8_1 + "```" + } + ], + footer: { + icon_url: guild.iconURL() || "", + text: "ID: " + user.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) + ) + ] + }) } } as Button diff --git a/src/components/buttons/guildinactivitylog.ts b/src/components/buttons/guildinactivitylog.ts index 7b26869..95a7e0a 100644 --- a/src/components/buttons/guildinactivitylog.ts +++ b/src/components/buttons/guildinactivitylog.ts @@ -1,35 +1,13 @@ -import { - ButtonBuilder, - ActionRowBuilder, - ButtonStyle, - EmbedBuilder, - GuildMember, - TextChannel -} from "discord.js" -import { - gm, - manager, - moderator, - beast, - member, - guildStaff, - guildRole -} from "config/roles.json" +import { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder, GuildMember, TextChannel } from "discord.js" +import { gm, manager, moderator, beast, member, guildStaff, guildRole } from "config/roles.json" import { ignM, smallM, largeM } from "config/limitmessages.json" import { inactivity } from "config/questions.json" import { color, inactivityLogChannel } from "config/options.json" import { Button } from "interfaces" -const guildRoles = [ - gm, - manager, - moderator, - beast, - member, - guildStaff, - guildRole -] +import { getIGN } from "utils/Hypixel" +const guildRoles = [gm, manager, moderator, beast, member, guildStaff, guildRole] -module.exports = { +export = { name: "guildinactivitylog", description: "Configure the bot.", @@ -38,7 +16,6 @@ module.exports = { const user = interaction.member as GuildMember const embedColor = Number(color.replace("#", "0x")) const userRoles = user.roles.cache - const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" if (!userRoles.some(role => guildRoles.includes(role.id))) { return await interaction.reply({ @@ -62,25 +39,20 @@ module.exports = { .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." - ) + .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") .setColor(embedColor) try { await user.send({ - embeds: [ - { - title: "Guild Inactivity Log", - description: - "Please answer the following questions to submit an inactivity log for the guild.\n" + - "If you wish to cancel your form, please press type `cancel` at any time.\n" + - "If you wish to proceed with your form, please type `yes`.\n\n" + - "**Do not upload images, videos, or GIFS.**\n" + - "You have a minute to respond to this message.", - color: embedColor - } - ] + embeds: [{ + title: "Guild Inactivity Log", + description: "Please answer the following questions to submit an inactivity log for the guild.\n" + + "If you wish to cancel your form, please press type `cancel` at any time.\n" + + "If you wish to proceed with your form, 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) { return await interaction.reply({ @@ -113,20 +85,14 @@ module.exports = { } await user.send({ - embeds: [ - { - title: "**Question 1**", - description: - sq(1) + - "\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." - } + embeds: [{ + title: "**Question 1**", + description: sq(1) + "\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({ @@ -140,27 +106,10 @@ module.exports = { } if (answer1.first()!.content.length > 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 - } - ] + embeds: [{ + description: "Max character limit is 16.", + color: embedColor + }] }) return } @@ -172,23 +121,27 @@ module.exports = { await user.send({ embeds: [cancelled] }) return } + if (await getIGN(answer1.first()!.content)) { + await user.send({ + embeds: [{ + description: "That is not a valid Minecraft username.\n" + + "Application cancelled.", + color: embedColor + }] + }) + return + } const answer1_1 = answer1.first()!.content await user.send({ - embeds: [ - { - title: "**Question 2**", - description: - sq(2) + - "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + - smallM + - "`", - color: embedColor, - footer: { - text: "You have 5 minutes to respond to this message." - } + embeds: [{ + title: "**Question 2**", + description: sq(2) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", + color: embedColor, + footer: { + text: "You have 5 minutes to respond to this message." } - ] + }] }) const answer2 = await user.dmChannel!.awaitMessages({ filter: m => m.author.id === user.user.id, @@ -201,12 +154,10 @@ module.exports = { } if (answer2.first()!.content.length > 128) { await user.send({ - embeds: [ - { - description: "Max character limit is 128.", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 128.", + color: embedColor + }] }) return } @@ -221,20 +172,14 @@ module.exports = { const answer2_1 = answer1.first()!.content await user.send({ - embeds: [ - { - title: "**Question 3**", - description: - sq(3) + - "\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." - } + embeds: [{ + title: "**Question 3**", + description: sq(3) + "\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.user.id, @@ -247,12 +192,10 @@ module.exports = { } if (answer3.first()!.content.length > 256) { await user.send({ - embeds: [ - { - description: "Max character limit is 256", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 256", + color: embedColor + }] }) return } @@ -267,13 +210,10 @@ module.exports = { const answer3_1 = answer1.first()!.content await user.send({ - embeds: [ - { - description: - "If you want to submit your application, type `yes` if not, type `no`", - color: embedColor - } - ] + 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.user.id, @@ -294,50 +234,40 @@ module.exports = { } await user.send({ - embeds: [ - { - description: "Your application has been submitted!", - color: embedColor - } - ] + embeds: [{ + description: "Your application has been submitted!", + color: embedColor + }] }) - const appChannel = guild.channels.cache.get( - inactivityLogChannel - ) as TextChannel + const appChannel = guild.channels.cache.get(inactivityLogChannel) as TextChannel await appChannel.send({ - embeds: [ - { - title: - user.user.username + - "#" + - user.user.discriminator + - " - Inactivity Application", - color: embedColor, - thumbnail: { - url: user.avatarURL() || "" + embeds: [{ + title: user.user.username + "#" + user.user.discriminator + " - Inactivity Application", + color: embedColor, + thumbnail: { + url: user.avatarURL() || "" + }, + fields: [ + { + name: rq(1), + value: "`" + answer1_1 + "`" }, - fields: [ - { - name: rq(1), - value: "`" + answer1_1 + "`" - }, - { - name: rq(2), - value: "`" + answer2_1 + "`" - }, - { - name: rq(3), - value: "`" + answer3_1 + "`" - } - ], - footer: { - icon_url: user.avatarURL() || undefined, - text: "ID: " + user.user.id + { + name: rq(2), + value: "`" + answer2_1 + "`" + }, + { + name: rq(3), + value: "`" + answer3_1 + "`" } + ], + footer: { + icon_url: user.avatarURL() || undefined, + text: "ID: " + user.user.id } - ], + }], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() diff --git a/src/components/buttons/staffapplicationaccept.ts b/src/components/buttons/staffapplicationaccept.ts index 84e8ea4..ce3380a 100644 --- a/src/components/buttons/staffapplicationaccept.ts +++ b/src/components/buttons/staffapplicationaccept.ts @@ -19,17 +19,13 @@ export = { const applicantId = embed.footer!.text.split(" ")[1] const applicant = await guild.members.fetch(applicantId) - const applicantUsername = - applicant.user.username + "#" + applicant.user.discriminator + const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator await applicant.send({ - embeds: [ - { - description: - "Your application for the Illegitimate staff team has been accepted.", - color: embedColor - } - ] + embeds: [{ + description: "Your application for the Illegitimate staff team has been accepted.", + color: embedColor + }] }) await message.edit({ @@ -52,20 +48,18 @@ export = { await staffapp.findOneAndDelete({ userID: applicantId }) await interaction.editReply({ - embeds: [ - { - title: applicantUsername + " - Staff Application.", - description: "Application accepted by <@" + user.id + ">.", - color: embedColor, - thumbnail: { - url: applicant.avatarURL() || "" - }, - footer: { - icon_url: guild.iconURL() || undefined, - text: "ID: " + applicantId - } + embeds: [{ + title: applicantUsername + " - Staff Application.", + description: "Application accepted by <@" + user.id + ">.", + color: embedColor, + thumbnail: { + url: applicant.avatarURL() || "" + }, + footer: { + icon_url: guild.iconURL() || undefined, + text: "ID: " + applicantId } - ] + }] }) } } as Button diff --git a/src/components/buttons/staffapplicationdeny.ts b/src/components/buttons/staffapplicationdeny.ts index 13d6275..6b3be04 100644 --- a/src/components/buttons/staffapplicationdeny.ts +++ b/src/components/buttons/staffapplicationdeny.ts @@ -1,9 +1,4 @@ -import { - ModalBuilder, - ActionRowBuilder, - TextInputBuilder, - TextInputStyle -} from "discord.js" +import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js" import { Button } from "interfaces" export = { @@ -20,9 +15,7 @@ export = { .setLabel("Deny Reason") .setCustomId("staffdenyreason") .setStyle(TextInputStyle.Paragraph) - .setPlaceholder( - "Enter a reason for denying the application" - ) + .setPlaceholder( "Enter a reason for denying the application") .setRequired(false) ) ) diff --git a/src/components/buttons/staffapply.ts b/src/components/buttons/staffapply.ts index b7d5237..3c8b3d3 100644 --- a/src/components/buttons/staffapply.ts +++ b/src/components/buttons/staffapply.ts @@ -1,11 +1,4 @@ -import { - ButtonBuilder, - ButtonStyle, - ActionRowBuilder, - EmbedBuilder, - GuildMember, - TextChannel -} from "discord.js" +import { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder, GuildMember, TextChannel } from "discord.js" import { color, staffApplicationsChannel } from "config/options.json" import { largeM, ignM } from "config/limitmessages.json" import questions from "config/questions.json" @@ -43,17 +36,13 @@ export = { if (user.user.id !== env.prod.dev) { if (status === "0") { - await interaction.editReply( - "Staff applications are currently closed." - ) + await interaction.editReply("Staff applications are currently closed.") return } } if (!userRoles.has(guildRole)) { - await interaction.editReply( - "You must be a member of the guild to apply for staff." - ) + await interaction.editReply("You must be a member of the guild to apply for staff.") return } @@ -65,9 +54,7 @@ export = { const application = await staffapp.findOne({ userID: user.user.id }) if (application) { - await interaction.editReply( - "You already have an application in progress." - ) + await interaction.editReply("You already have an application in progress.") return } @@ -78,23 +65,18 @@ export = { .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." - ) + .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: - "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" + - "**Do not upload images, videos, or GIFS.**\n" + - "You have a minute to respond to this message.", - color: embedColor - } - ] + embeds: [{ + title: "Staff Application", + description: "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\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("Please enable your DMs.") @@ -123,20 +105,14 @@ export = { // first question await user.send({ - embeds: [ - { - title: "**Question 1**", - description: - sq(1) + - "\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." - } + embeds: [{ + title: "**Question 1**", + description: sq(1) + "\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.user.id, @@ -157,26 +133,21 @@ export = { } if (answer1.first()!.content.length > 16) { await user.send({ - embeds: [ - { - description: "Max character limit is 16.", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 16.", + color: embedColor + }] }) return } const uuid = await getUUID(answer1.first()!.content) if (!uuid) { await user.send({ - embeds: [ - { - description: - "That is not a valid Minecraft username.\n" + - "Application cancelled.", - color: embedColor - } - ] + embeds: [{ + description: "That is not a valid Minecraft username.\n" + + "Application cancelled.", + color: embedColor + }] }) return } @@ -184,19 +155,15 @@ export = { // second question await user.send({ - embeds: [ - { - title: "**Question 2**", - description: - sq(2) + - "\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." - } + embeds: [{ + title: "**Question 2**", + description: sq(2) + "\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.user.id, @@ -217,12 +184,10 @@ export = { } if (answer2.first()!.content.length > 64) { await user.send({ - embeds: [ - { - description: "Max character limit is 64.", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 64.", + color: embedColor + }] }) return } @@ -230,20 +195,14 @@ export = { // third question await user.send({ - embeds: [ - { - title: "**Question 3**", - description: - sq(3) + - "\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." - } + embeds: [{ + title: "**Question 3**", + description: sq(3) + "\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.user.id, @@ -264,32 +223,24 @@ export = { } if (answer3.first()!.content.length > 256) { await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] }) } const answer3_1 = answer3.first()!.content // fourth question await user.send({ - embeds: [ - { - title: "**Question 4**", - description: - sq(4) + - "\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." - } + embeds: [{ + title: "**Question 4**", + description: sq(4) + "\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.user.id, @@ -310,32 +261,24 @@ export = { } if (answer4.first()!.content.length > 256) { await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] }) } const answer4_1 = answer4.first()!.content // fifth question await user.send({ - embeds: [ - { - title: "**Question 5**", - description: - sq(5) + - "\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." - } + embeds: [{ + title: "**Question 5**", + description: sq(5) + "\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.user.id, @@ -356,33 +299,25 @@ export = { } if (answer5.first()!.content.length > 256) { await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] }) } const answer5_1 = answer5.first()!.content // sixth question await user.send({ - embeds: [ - { - title: "**Question 6**", - description: - sq(6) + - "\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." - } + embeds: [{ + title: "**Question 6**", + description: sq(6) + "\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.user.id, @@ -403,24 +338,19 @@ export = { } if (answer6.first()!.content.length > 256) { await user.send({ - embeds: [ - { - description: "Max character limit is 256.", - color: embedColor - } - ] + embeds: [{ + description: "Max character limit is 256.", + color: embedColor + }] }) } const answer6_1 = answer6.first()!.content await user.send({ - embeds: [ - { - description: - "If you want to submit your application, type `yes` if not, type `no`", - color: embedColor - } - ] + embeds: [{ + description: "If you want to submit your application, type `yes` if not, type `no`", + color: embedColor + }] }) const final = await user.dmChannel!.awaitMessages({ @@ -442,12 +372,10 @@ export = { } await user.send({ - embeds: [ - { - description: "Your application has been submitted!", - color: embedColor - } - ] + embeds: [{ + description: "Your application has been submitted!", + color: embedColor + }] }) const newStaffApp = new staffapp({ @@ -459,54 +387,46 @@ export = { await newStaffApp.save() await user.deleteDM() - const channel = guild.channels.cache.get( - staffApplicationsChannel - ) as TextChannel + const channel = guild.channels.cache.get(staffApplicationsChannel) as TextChannel await channel.send({ - embeds: [ - { - title: - user.user.username + - "#" + - user.user.discriminator + - " - Staff Application", - color: embedColor, - thumbnail: { - url: user.avatarURL() || "" + embeds: [{ + title: user.user.username + "#" + user.user.discriminator + " - Staff Application", + color: embedColor, + thumbnail: { + url: user.avatarURL() || "" + }, + fields: [ + { + name: rq(1), + value: "```" + answer1_1 + "```" }, - fields: [ - { - name: rq(1), - value: "```" + answer1_1 + "```" - }, - { - name: rq(2), - value: "```" + answer2_1 + "```" - }, - { - name: rq(3), - value: "```" + answer3_1 + "```" - }, - { - name: rq(4), - value: "```" + answer4_1 + "```" - }, - { - name: rq(5), - value: "```" + answer5_1 + "```" - }, - { - name: rq(6), - value: "```" + answer6_1 + "```" - } - ], - footer: { - icon_url: guild.iconURL() || undefined, - text: "ID: " + user.user.id + { + name: rq(2), + value: "```" + answer2_1 + "```" + }, + { + name: rq(3), + value: "```" + answer3_1 + "```" + }, + { + name: rq(4), + value: "```" + answer4_1 + "```" + }, + { + name: rq(5), + value: "```" + answer5_1 + "```" + }, + { + name: rq(6), + value: "```" + answer6_1 + "```" } + ], + footer: { + icon_url: guild.iconURL() || undefined, + text: "ID: " + user.user.id } - ], + }], components: [ new ActionRowBuilder().addComponents( new ButtonBuilder() diff --git a/src/components/buttons/verify.ts b/src/components/buttons/verify.ts index 04bfab7..0e7dd19 100644 --- a/src/components/buttons/verify.ts +++ b/src/components/buttons/verify.ts @@ -1,9 +1,4 @@ -import { - ModalBuilder, - ActionRowBuilder, - TextInputBuilder, - TextInputStyle -} from "discord.js" +import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js" import { Button } from "interfaces" export = { diff --git a/src/components/buttons/waitingListUpdate.ts b/src/components/buttons/waitingListUpdate.ts index 4063adf..b76a889 100644 --- a/src/components/buttons/waitingListUpdate.ts +++ b/src/components/buttons/waitingListUpdate.ts @@ -37,20 +37,18 @@ export = { } await message.edit({ - embeds: [ - { - title: embed.title!, - description: embed.description!, - color: embed.color!, - footer: { - text: "Last updated by " + user.username, - icon_url: user.avatarURL() || undefined - }, - thumbnail: embed.thumbnail!, - fields: fields, - timestamp: new Date().toISOString() - } - ] + embeds: [{ + title: embed.title!, + description: embed.description!, + color: embed.color!, + footer: { + text: "Last updated by " + user.username, + icon_url: user.avatarURL() || undefined + }, + thumbnail: embed.thumbnail!, + fields: fields, + timestamp: new Date().toISOString() + }] }) await interaction.editReply("Updated the waiting list")