Updated application system

This commit is contained in:
2024-02-23 12:40:00 +01:00
parent 136b53c6a4
commit 1480713ee0
4 changed files with 173 additions and 538 deletions

View File

@@ -1,12 +1,12 @@
import { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder, GuildMember, TextChannel } from "discord.js" import { ButtonBuilder, ButtonStyle, ActionRowBuilder, GuildMember, TextChannel } from "discord.js"
import { embedColor, applicationsChannel } from "config/options" import { embedColor, applicationsChannel } from "config/options"
import { largeM, smallM, ignM } from "config/limitmessages" import { largeM, smallM, ignM } from "config/limitmessages"
import questions from "config/questions" import questions from "config/questions"
import { guildRole } from "config/roles" import { guildRole } from "config/roles"
import { getUUID } from "utils/Hypixel"
import mongoose from "mongoose" import mongoose from "mongoose"
import guildapp from "schemas/guildAppSchema" import guildapp from "schemas/guildAppSchema"
import { IButton } from "interfaces" import { IButton } from "interfaces"
import applicationQuestions from "utils/functions/applicationquestions"
export = { export = {
name: "guildapply", name: "guildapply",
@@ -39,16 +39,6 @@ export = {
return 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 { try {
await user.send({ await user.send({
embeds: [{ embeds: [{
@@ -71,18 +61,8 @@ export = {
max: 1, max: 1,
time: 1000 * 60 time: 1000 * 60
}) })
if (input.size === 0) { const confirm1 = await applicationQuestions(input, user, 0, "confirmation")
await user.send({ embeds: [tooLong] }) if (!confirm1) return
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 // first question
await user.send({ await user.send({
@@ -95,44 +75,16 @@ export = {
} }
}] }]
}) })
const answer1 = await user.dmChannel!.awaitMessages({
const useranswer1 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5
}) })
if (answer1.size === 0) { const answer1Obj = await applicationQuestions(useranswer1, user, 16, "ign") as boolean | { answer: string, uuid: string }
await user.send({ embeds: [tooLong] }) if (answer1Obj === false || answer1Obj === true) return
return const answer1 = answer1Obj.answer
} const uuid = answer1Obj.uuid
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
// second question // second question
await user.send({ await user.send({
@@ -145,33 +97,14 @@ export = {
} }
}] }]
}) })
const answer2 = await user.dmChannel!.awaitMessages({
const useranswer2 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer2.size === 0) { const answer2 = await applicationQuestions(useranswer2, user, 8, "normal")
await user.send({ embeds: [tooLong] }) if (!answer2) return
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 // third question
await user.send({ await user.send({
@@ -184,32 +117,14 @@ export = {
} }
}] }]
}) })
const answer3 = await user.dmChannel!.awaitMessages({
const useranswer3 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer3.size === 0) { const answer3 = await applicationQuestions(useranswer3, user, 128, "normal")
await user.send({ embeds: [tooLong] }) if (!answer3) return
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
// fourth question // fourth question
await user.send({ await user.send({
@@ -223,32 +138,14 @@ export = {
} }
}] }]
}) })
const answer4 = await user.dmChannel!.awaitMessages({
const useranswer4 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer4.size === 0) { const answer4 = await applicationQuestions(useranswer4, user, 256, "normal")
await user.send({ embeds: [tooLong] }) if (!answer4) return
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 // fifth question
await user.send({ await user.send({
@@ -261,32 +158,14 @@ export = {
} }
}] }]
}) })
const answer5 = await user.dmChannel!.awaitMessages({
const useranswer5 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer5.size === 0) { const answer5 = await applicationQuestions(useranswer5, user, 128, "normal")
await user.send({ embeds: [tooLong] }) if (!answer5) return
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 // sixth question
await user.send({ await user.send({
@@ -299,32 +178,14 @@ export = {
} }
}] }]
}) })
const answer6 = await user.dmChannel!.awaitMessages({
const useranswer6 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer6.size === 0) { const answer6 = await applicationQuestions(useranswer6, user, 256, "normal")
await user.send({ embeds: [tooLong] }) if (!answer6) return
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 // seventh question
await user.send({ await user.send({
@@ -337,32 +198,14 @@ export = {
} }
}] }]
}) })
const answer7 = await user.dmChannel!.awaitMessages({
const useranswer7 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer7.size === 0) { const answer7 = await applicationQuestions(useranswer7, user, 128, "normal")
await user.send({ embeds: [tooLong] }) if (!answer7) return
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 // eighth question
await user.send({ await user.send({
@@ -375,32 +218,14 @@ export = {
} }
}] }]
}) })
const answer8 = await user.dmChannel!.awaitMessages({
const useranswer8 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer8.size === 0) { const answer8 = await applicationQuestions(useranswer8, user, 64, "normal")
await user.send({ embeds: [tooLong] }) if (!answer8) return
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({ await user.send({
embeds: [{ embeds: [{
@@ -414,18 +239,8 @@ export = {
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5
}) })
if (final.size === 0) { const confirm2 = await applicationQuestions(final, user, 0, "confirmation")
await user.send({ embeds: [tooLong] }) if (!confirm2) return
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({ await user.send({
embeds: [{ embeds: [{
@@ -453,35 +268,35 @@ export = {
fields: [ fields: [
{ {
name: rq(1), name: rq(1),
value: "```" + answer1_1 + "```" value: "```" + answer1 + "```"
}, },
{ {
name: rq(2), name: rq(2),
value: "```" + answer2_1 + "```" value: "```" + answer2 + "```"
}, },
{ {
name: rq(3), name: rq(3),
value: "```" + answer3_1 + "```" value: "```" + answer3 + "```"
}, },
{ {
name: rq(4), name: rq(4),
value: "```" + answer4_1 + "```" value: "```" + answer4 + "```"
}, },
{ {
name: rq(5), name: rq(5),
value: "```" + answer5_1 + "```" value: "```" + answer5 + "```"
}, },
{ {
name: rq(6), name: rq(6),
value: "```" + answer6_1 + "```" value: "```" + answer6 + "```"
}, },
{ {
name: rq(7), name: rq(7),
value: "```" + answer7_1 + "```" value: "```" + answer7 + "```"
}, },
{ {
name: rq(8), name: rq(8),
value: "```" + answer8_1 + "```" value: "```" + answer8 + "```"
} }
], ],
footer: { footer: {

View File

@@ -1,10 +1,10 @@
import { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder, GuildMember, TextChannel } from "discord.js" import { ButtonBuilder, ActionRowBuilder, ButtonStyle, GuildMember, TextChannel } from "discord.js"
import { gm, manager, moderator, beast, member, guildStaff, guildRole } from "config/roles" import { gm, manager, moderator, beast, member, guildStaff, guildRole } from "config/roles"
import { ignM, smallM, largeM } from "config/limitmessages" import { ignM, smallM, largeM } from "config/limitmessages"
import { inactivity } from "config/questions" import { inactivity } from "config/questions"
import { embedColor, inactivityLogChannel } from "config/options" import { embedColor, inactivityLogChannel } from "config/options"
import { IButton } from "interfaces" import { IButton } from "interfaces"
import { getIGN } from "utils/Hypixel" import applicationQuestions from "utils/functions/applicationquestions"
const guildRoles = [gm, manager, moderator, beast, member, guildStaff, guildRole] const guildRoles = [gm, manager, moderator, beast, member, guildStaff, guildRole]
export = { export = {
@@ -31,16 +31,6 @@ export = {
return inactivity[n - 1].r return inactivity[n - 1].r
} }
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 { try {
await user.send({ await user.send({
embeds: [{ embeds: [{
@@ -70,18 +60,8 @@ export = {
max: 1, max: 1,
time: 1000 * 60 time: 1000 * 60
}) })
if (input.first()!.attachments.size > 0) { const confirm1 = await applicationQuestions(input, user, 0, "confirmation")
await user.send({ embeds: [attachments] }) if (!confirm1) return
return
}
if (input.size === 0) {
await user.send({ embeds: [tooLong] })
return
}
if (input.first()!.content.toLowerCase() !== "yes") {
await user.send({ embeds: [cancelled] })
return
}
await user.send({ await user.send({
embeds: [{ embeds: [{
@@ -94,43 +74,14 @@ export = {
}] }]
}) })
const answer1 = await user.dmChannel!.awaitMessages({ const useranswer1 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5
}) })
if (answer1.first()!.attachments.size > 0) { const answer1Obj = await applicationQuestions(useranswer1, user, 16, "ign") as boolean | { answer: string, uuid: string }
await user.send({ embeds: [attachments] }) if (answer1Obj === false || answer1Obj === true) return
return const answer1 = answer1Obj.answer
}
if (answer1.first()!.content.length > 16) {
await user.send({
embeds: [{
description: "Max character limit is 16.",
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
}
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({ await user.send({
embeds: [{ embeds: [{
@@ -142,33 +93,13 @@ export = {
} }
}] }]
}) })
const answer2 = await user.dmChannel!.awaitMessages({ const useranswer2 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5
}) })
if (answer2.first()!.attachments.size > 0) { const answer2 = await applicationQuestions(useranswer2, user, 128, "normal")
await user.send({ embeds: [attachments] }) if (!answer2) return
return
}
if (answer2.first()!.content.length > 128) {
await user.send({
embeds: [{
description: "Max character limit is 128.",
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 answer2_1 = answer1.first()!.content
await user.send({ await user.send({
embeds: [{ embeds: [{
@@ -180,33 +111,13 @@ export = {
} }
}] }]
}) })
const answer3 = await user.dmChannel!.awaitMessages({ const useranswer3 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer3.first()!.attachments.size > 0) { const answer3 = await applicationQuestions(useranswer3, user, 256, "normal")
await user.send({ embeds: [attachments] }) if (!answer3) return
return
}
if (answer3.first()!.content.length > 256) {
await user.send({
embeds: [{
description: "Max character limit is 256",
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 answer3_1 = answer1.first()!.content
await user.send({ await user.send({
embeds: [{ embeds: [{
@@ -219,18 +130,8 @@ export = {
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5
}) })
if (final.first()!.attachments.size > 0) { const confirm2 = await applicationQuestions(final, user, 0, "confirmation")
await user.send({ embeds: [attachments] }) if (!confirm2) return
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({ await user.send({
embeds: [{ embeds: [{
@@ -251,15 +152,15 @@ export = {
fields: [ fields: [
{ {
name: rq(1), name: rq(1),
value: "`" + answer1_1 + "`" value: "`" + answer1 + "`"
}, },
{ {
name: rq(2), name: rq(2),
value: "`" + answer2_1 + "`" value: "`" + answer2 + "`"
}, },
{ {
name: rq(3), name: rq(3),
value: "`" + answer3_1 + "`" value: "`" + answer3 + "`"
} }
], ],
footer: { footer: {

View File

@@ -1,4 +1,4 @@
import { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder, GuildMember, TextChannel } from "discord.js" import { ButtonBuilder, ButtonStyle, ActionRowBuilder, GuildMember, TextChannel } from "discord.js"
import { embedColor, staffApplicationsChannel } from "config/options" import { embedColor, staffApplicationsChannel } from "config/options"
import { largeM, ignM } from "config/limitmessages" import { largeM, ignM } from "config/limitmessages"
import questions from "config/questions" import questions from "config/questions"
@@ -6,9 +6,9 @@ import { guildRole, guildStaff } from "config/roles"
import mongoose from "mongoose" import mongoose from "mongoose"
import staffapp from "schemas/staffAppSchema" import staffapp from "schemas/staffAppSchema"
import settings from "schemas/settingsSchema" import settings from "schemas/settingsSchema"
import { getUUID } from "utils/Hypixel"
import { IButton } from "interfaces" import { IButton } from "interfaces"
import env from "utils/Env" import env from "utils/Env"
import applicationQuestions from "utils/functions/applicationquestions"
export = { export = {
name: "staffapply", name: "staffapply",
@@ -57,16 +57,6 @@ export = {
return 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 { try {
await user.send({ await user.send({
embeds: [{ embeds: [{
@@ -89,18 +79,8 @@ export = {
max: 1, max: 1,
time: 1000 * 60 time: 1000 * 60
}) })
if (input.size === 0) { const confirm1 = await applicationQuestions(input, user, 0, "confirmation")
await user.send({ embeds: [tooLong] }) if (!confirm1) return
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 // first question
await user.send({ await user.send({
@@ -113,44 +93,15 @@ export = {
} }
}] }]
}) })
const answer1 = await user.dmChannel!.awaitMessages({ const useranswer1 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5
}) })
if (answer1.size === 0) { const answer1Obj = await applicationQuestions(useranswer1, user, 16, "ign") as boolean | { answer: string, uuid: string }
await user.send({ embeds: [tooLong] }) if (answer1Obj === false || answer1Obj === true) return
return const answer1 = answer1Obj.answer
} const uuid = answer1Obj.uuid
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
// second question // second question
await user.send({ await user.send({
@@ -164,33 +115,13 @@ export = {
} }
}] }]
}) })
const answer2 = await user.dmChannel!.awaitMessages({ const useranswer2 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer2.size === 0) { const answer2 = await applicationQuestions(useranswer2, user, 64, "normal")
await user.send({ embeds: [tooLong] }) if (!answer2) return
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 > 64) {
await user.send({
embeds: [{
description: "Max character limit is 64.",
color: embedColor
}]
})
return
}
const answer2_1 = answer2.first()!.content
// third question // third question
await user.send({ await user.send({
@@ -203,32 +134,13 @@ export = {
} }
}] }]
}) })
const answer3 = await user.dmChannel!.awaitMessages({ const useranswer3 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer3.size === 0) { const answer3 = await applicationQuestions(useranswer3, user, 256, "normal")
await user.send({ embeds: [tooLong] }) if (!answer3) return
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 > 256) {
await user.send({
embeds: [{
description: "Max character limit is 256.",
color: embedColor
}]
})
}
const answer3_1 = answer3.first()!.content
// fourth question // fourth question
await user.send({ await user.send({
@@ -241,32 +153,13 @@ export = {
} }
}] }]
}) })
const answer4 = await user.dmChannel!.awaitMessages({ const useranswer4 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer4.size === 0) { const answer4 = await applicationQuestions(useranswer4, user, 256, "normal")
await user.send({ embeds: [tooLong] }) if (!answer4) return
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 // fifth question
await user.send({ await user.send({
@@ -279,32 +172,13 @@ export = {
} }
}] }]
}) })
const answer5 = await user.dmChannel!.awaitMessages({ const useranswer5 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer5.size === 0) { const answer5 = await applicationQuestions(useranswer5, user, 256, "normal")
await user.send({ embeds: [tooLong] }) if (!answer5) return
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 > 256) {
await user.send({
embeds: [{
description: "Max character limit is 256.",
color: embedColor
}]
})
}
const answer5_1 = answer5.first()!.content
// sixth question // sixth question
await user.send({ await user.send({
@@ -318,32 +192,13 @@ export = {
} }
}] }]
}) })
const answer6 = await user.dmChannel!.awaitMessages({ const useranswer6 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15
}) })
if (answer6.size === 0) { const answer6 = await applicationQuestions(useranswer6, user, 256, "normal")
await user.send({ embeds: [tooLong] }) if (!answer6) return
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
await user.send({ await user.send({
embeds: [{ embeds: [{
@@ -357,18 +212,8 @@ export = {
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5
}) })
if (final.size === 0) { const confirm2 = await applicationQuestions(final, user, 0, "confirmation")
await user.send({ embeds: [tooLong] }) if (!confirm2) return
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({ await user.send({
embeds: [{ embeds: [{
@@ -398,27 +243,27 @@ export = {
fields: [ fields: [
{ {
name: rq(1), name: rq(1),
value: "```" + answer1_1 + "```" value: "```" + answer1 + "```"
}, },
{ {
name: rq(2), name: rq(2),
value: "```" + answer2_1 + "```" value: "```" + answer2 + "```"
}, },
{ {
name: rq(3), name: rq(3),
value: "```" + answer3_1 + "```" value: "```" + answer3 + "```"
}, },
{ {
name: rq(4), name: rq(4),
value: "```" + answer4_1 + "```" value: "```" + answer4 + "```"
}, },
{ {
name: rq(5), name: rq(5),
value: "```" + answer5_1 + "```" value: "```" + answer5 + "```"
}, },
{ {
name: rq(6), name: rq(6),
value: "```" + answer6_1 + "```" value: "```" + answer6 + "```"
} }
], ],
footer: { footer: {

View File

@@ -0,0 +1,74 @@
import { embedColor } from "config/options"
import { Collection, EmbedBuilder, GuildMember, Message } from "discord.js"
import { getUUID } from "utils/Hypixel"
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)
export default async function applicationQuestions(
input: Collection<string, Message<boolean>>,
user: GuildMember,
length: number,
questiontype: "ign" | "confirmation" | "normal"
) {
if (questiontype === "confirmation") {
if (input.size === 0) {
await user.send({ embeds: [tooLong] })
return false
}
if (input.first()!.content.toLowerCase() !== "yes") {
await user.send({ embeds: [cancelled] })
return false
}
if (input.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] })
return false
}
return true
} else {
if (input.size === 0) {
await user.send({ embeds: [tooLong] })
return false
}
if (input.first()!.content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] })
return false
}
if (input.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] })
return false
}
if (input.first()!.content.length > length) {
await user.send({
embeds: [{
description: `Max character limit is ${length}.`,
color: embedColor
}]
})
return false
}
if (questiontype === "ign") {
const uuid = await getUUID(input.first()!.content)
if (!uuid) {
await user.send({
embeds: [{
description: "That is not a valid Minecraft username.\n" +
"Application cancelled.",
color: embedColor
}]
})
return false
}
return { answer: input.first()!.content, uuid: uuid }
}
return input!.first()!.content
}
}