Updated buttons and etc to components folder
This commit is contained in:
40
src/components/autocomplete/unban.ts
Normal file
40
src/components/autocomplete/unban.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Autocomplete } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "unban",
|
||||
description: "Unban a user from the server",
|
||||
type: "autocomplete",
|
||||
|
||||
async execute(interaction) {
|
||||
const focusedOption = interaction.options.getFocused(true)
|
||||
if (focusedOption.name !== "user") {
|
||||
return
|
||||
}
|
||||
|
||||
if (focusedOption.value === "") {
|
||||
await interaction.respond([
|
||||
{
|
||||
name: "Please start typing a username to unban",
|
||||
value: "none",
|
||||
},
|
||||
])
|
||||
return
|
||||
}
|
||||
|
||||
const bannedUsers = await interaction.guild!.bans.fetch()
|
||||
const filteredUsers = bannedUsers.filter(user =>
|
||||
user.user.username
|
||||
.toLowerCase()
|
||||
.includes(focusedOption.value.toLowerCase()),
|
||||
)
|
||||
|
||||
const results = filteredUsers.map(user => ({
|
||||
name: user.user.username,
|
||||
value: user.user.id,
|
||||
}))
|
||||
|
||||
await interaction.respond(results.slice(0, 25)).catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
} as Autocomplete
|
||||
246
src/components/buttons/checkstats.ts
Normal file
246
src/components/buttons/checkstats.ts
Normal file
@@ -0,0 +1,246 @@
|
||||
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 { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "checkstats",
|
||||
description: "Check your stats.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply()
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer!.text.split(" ")[1]
|
||||
const guildappdata = await guildapp.findOne({ userID: applicantId })
|
||||
const uuid = guildappdata!.uuid
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description:
|
||||
"That player hasn't played Hypixel before.",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const ign = player.playername
|
||||
const head = await getHeadURL(ign)
|
||||
const rank2 = player.newPackageRank
|
||||
const monthlyRank = player.monthlyPackageRank
|
||||
|
||||
let rank = ""
|
||||
if (rank2 === "VIP") {
|
||||
rank = "[VIP] "
|
||||
} else if (rank2 === "VIP_PLUS") {
|
||||
rank = "[VIP+] "
|
||||
} else if (rank2 === "MVP") {
|
||||
rank = "[MVP] "
|
||||
} else if (rank2 === "MVP_PLUS" && monthlyRank === "NONE") {
|
||||
rank = "[MVP+] "
|
||||
} else if (rank2 === "MVP_PLUS" && monthlyRank === "SUPERSTAR") {
|
||||
rank = "[MVP++] "
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
let guildName = ""
|
||||
if (!guild) {
|
||||
guildName = "None"
|
||||
} else {
|
||||
guildName = guild.name
|
||||
}
|
||||
|
||||
let guildTag = ""
|
||||
if (!guild) {
|
||||
guildTag = ""
|
||||
} else if (!guild.tag) {
|
||||
guildTag = ""
|
||||
} else {
|
||||
guildTag = " [" + guild.tag + "]"
|
||||
}
|
||||
|
||||
let guildRank
|
||||
if (!guild) {
|
||||
guildRank = "N/A"
|
||||
} else {
|
||||
guildRank = guild.members.find(m => m.uuid === uuid)!.rank
|
||||
}
|
||||
|
||||
const statsFields = []
|
||||
if (!player.stats) {
|
||||
statsFields.push({
|
||||
name: "<a:_warning:1178350183457751100> This player never played any games.",
|
||||
value: "**➺ Stats:** `None`",
|
||||
})
|
||||
} else {
|
||||
if (player.stats.Bedwars) {
|
||||
const hsbwexp = player.stats?.Bedwars?.Experience || 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 =
|
||||
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
|
||||
} else {
|
||||
bwtitle =
|
||||
"<a:check_a:1087808632172847134> 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() +
|
||||
"`",
|
||||
})
|
||||
}
|
||||
|
||||
if (player.stats.SkyWars) {
|
||||
const hsswexp = player.stats.SkyWars.skywars_experience
|
||||
const hsswstars = skywarsLevel(hsswexp)
|
||||
const hsswkills = player.stats.SkyWars.kills
|
||||
const hsswdeaths = player.stats.SkyWars.deaths
|
||||
const hsswkd = hsswkills / hsswdeaths
|
||||
const hsswwins = player.stats.SkyWars.wins
|
||||
|
||||
let swtitle = ""
|
||||
if (hsswstars < swstars || hsswkd < swkdr) {
|
||||
swtitle =
|
||||
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
|
||||
} else {
|
||||
swtitle =
|
||||
"<a:check_a:1087808632172847134> 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() +
|
||||
"`",
|
||||
})
|
||||
}
|
||||
|
||||
if (player.stats.Duels) {
|
||||
const hsduelskills = player.stats.Duels.kills
|
||||
const hsduelsdeaths = player.stats.Duels.deaths
|
||||
const hsduelskd = hsduelskills / hsduelsdeaths
|
||||
const hsduelswins = player.stats.Duels.wins
|
||||
const hsduelslosses = player.stats.Duels.losses
|
||||
const hsduelswlr = hsduelswins / hsduelslosses
|
||||
|
||||
let duelstitle = ""
|
||||
if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
|
||||
duelstitle =
|
||||
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
|
||||
} else {
|
||||
duelstitle =
|
||||
"<a:check_a:1087808632172847134> 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() +
|
||||
"`",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// network level
|
||||
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()!,
|
||||
},
|
||||
fields: statsFields,
|
||||
},
|
||||
],
|
||||
})
|
||||
},
|
||||
} as Button
|
||||
98
src/components/buttons/guildapplicationaccept.ts
Normal file
98
src/components/buttons/guildapplicationaccept.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import { ActionRowBuilder, ButtonStyle, ButtonBuilder } from "discord.js"
|
||||
import { color } from "../../../config/options.json"
|
||||
import mongoose from "mongoose"
|
||||
import guildapp from "../../schemas/guildAppSchema"
|
||||
import waitingList from "../../schemas/waitinglistSchema"
|
||||
import { waitingListRole } from "../../../config/roles.json"
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "guildapplicationaccept",
|
||||
description: "Accept a guild application.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.user
|
||||
const guild = interaction.guild!
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer!.text.split(" ")[1]
|
||||
const applicantIGN = embed.fields[0].value.replaceAll("`", "")
|
||||
|
||||
const applicant = await guild.members.fetch(applicantId)
|
||||
const applicantUsername =
|
||||
applicant.user.username + "#" + applicant.user.discriminator
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>().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: [
|
||||
{
|
||||
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 })
|
||||
const applicantUUID = applicantEntry!.uuid
|
||||
const time = Date.now()
|
||||
|
||||
const waitingListAdd = new waitingList({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: applicantId,
|
||||
uuid: applicantUUID,
|
||||
IGN: applicantIGN,
|
||||
timestamp: time,
|
||||
})
|
||||
|
||||
await waitingListAdd.save()
|
||||
|
||||
await applicant.roles.add(waitingListRole)
|
||||
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() || guild.iconURL()!,
|
||||
},
|
||||
footer: {
|
||||
icon_url: guild.iconURL()!,
|
||||
text: "ID: " + applicant.id,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
},
|
||||
} as Button
|
||||
32
src/components/buttons/guildapplicationdeny.ts
Normal file
32
src/components/buttons/guildapplicationdeny.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
ModalBuilder,
|
||||
ActionRowBuilder,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js"
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "guildapplicationdeny",
|
||||
description: "Deny a guild application.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
const modal = new ModalBuilder()
|
||||
.setTitle("Deny Reason")
|
||||
.setCustomId("denyreasonbox")
|
||||
.setComponents(
|
||||
new ActionRowBuilder<TextInputBuilder>().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)
|
||||
},
|
||||
} as Button
|
||||
612
src/components/buttons/guildapply.ts
Normal file
612
src/components/buttons/guildapply.ts
Normal file
@@ -0,0 +1,612 @@
|
||||
import {
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
ActionRowBuilder,
|
||||
EmbedBuilder,
|
||||
GuildMember,
|
||||
GuildTextBasedChannel,
|
||||
} from "discord.js"
|
||||
import { color } from "../../../config/options.json"
|
||||
import { largeM, smallM, ignM } from "../../../config/limitmessages.json"
|
||||
import { applicationsChannel } from "../../../config/options.json"
|
||||
import questions from "../../../config/questions.json"
|
||||
import { guildRole } from "../../../config/roles.json"
|
||||
import { getUUID } from "../../utils/Hypixel"
|
||||
import mongoose from "mongoose"
|
||||
import guildapp from "../../schemas/guildAppSchema"
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "guildapply",
|
||||
description: "Guild application button.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
const user = interaction.member as GuildMember
|
||||
const guild = interaction.guild!
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
const userRoles = user.roles.cache.map(role => role.id)
|
||||
const guildQuestions = questions.guild
|
||||
|
||||
function qu(n: number): string {
|
||||
return guildQuestions[n - 1].q
|
||||
}
|
||||
|
||||
function rq(n: number): string {
|
||||
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
|
||||
}
|
||||
|
||||
const application = await guildapp.findOne({ userID: user.user.id })
|
||||
|
||||
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)
|
||||
|
||||
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 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("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
|
||||
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: [
|
||||
{
|
||||
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
|
||||
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: [
|
||||
{
|
||||
description: "Max character limit is 8.",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
const answer2_1 = answer2.first()!.content
|
||||
|
||||
// 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: [
|
||||
{
|
||||
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 GuildTextBasedChannel
|
||||
await channel.send({
|
||||
embeds: [
|
||||
{
|
||||
title:
|
||||
user.user.username +
|
||||
"#" +
|
||||
user.user.discriminator +
|
||||
" - Guild Application",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: user.avatarURL() || guild.iconURL()!,
|
||||
},
|
||||
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<ButtonBuilder>().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
|
||||
356
src/components/buttons/guildinactivitylog.ts
Normal file
356
src/components/buttons/guildinactivitylog.ts
Normal file
@@ -0,0 +1,356 @@
|
||||
import {
|
||||
ButtonBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonStyle,
|
||||
EmbedBuilder,
|
||||
GuildMember,
|
||||
GuildTextBasedChannel,
|
||||
} 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,
|
||||
]
|
||||
|
||||
module.exports = {
|
||||
name: "guildinactivitylog",
|
||||
description: "Configure the bot.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
const guild = interaction.guild!
|
||||
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({
|
||||
content: "Only guild members can use this button.",
|
||||
ephemeral: true,
|
||||
})
|
||||
}
|
||||
|
||||
function sq(n: number): string {
|
||||
return inactivity[n - 1].q
|
||||
}
|
||||
|
||||
function rq(n: number): string {
|
||||
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 {
|
||||
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,
|
||||
},
|
||||
],
|
||||
})
|
||||
} catch (error) {
|
||||
return await interaction.reply({
|
||||
content: "Please enable your DMs.",
|
||||
ephemeral: true,
|
||||
})
|
||||
}
|
||||
|
||||
await interaction.reply({
|
||||
content: "Please check your DMs.",
|
||||
ephemeral: true,
|
||||
})
|
||||
|
||||
const input = await user.dmChannel!.awaitMessages({
|
||||
filter: m => m.author.id === user.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
|
||||
}
|
||||
|
||||
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.",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const answer1 = await user.dmChannel!.awaitMessages({
|
||||
filter: m => m.author.id === user.user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5,
|
||||
})
|
||||
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
|
||||
}
|
||||
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
|
||||
|
||||
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.",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
const answer2 = await user.dmChannel!.awaitMessages({
|
||||
filter: m => m.author.id === user.user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5,
|
||||
})
|
||||
if (answer2.first()!.attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
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({
|
||||
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,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15,
|
||||
})
|
||||
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,
|
||||
},
|
||||
],
|
||||
})
|
||||
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({
|
||||
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.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 appChannel = guild.channels.cache.get(
|
||||
inactivityLogChannel,
|
||||
) as GuildTextBasedChannel
|
||||
|
||||
await appChannel.send({
|
||||
embeds: [
|
||||
{
|
||||
title:
|
||||
user.user.username +
|
||||
"#" +
|
||||
user.user.discriminator +
|
||||
" - Inactivity Application",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: user.displayAvatarURL({ forceStatic: false }),
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: rq(1),
|
||||
value: "`" + answer1_1 + "`",
|
||||
},
|
||||
{
|
||||
name: rq(2),
|
||||
value: "`" + answer2_1 + "`",
|
||||
},
|
||||
{
|
||||
name: rq(3),
|
||||
value: "`" + answer3_1 + "`",
|
||||
},
|
||||
],
|
||||
footer: {
|
||||
icon_url: user.displayAvatarURL({ forceStatic: false }),
|
||||
text: "ID: " + user.user.id,
|
||||
},
|
||||
},
|
||||
],
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("inactiveapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("inactiveapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
),
|
||||
],
|
||||
})
|
||||
},
|
||||
} as Button
|
||||
14
src/components/buttons/inactiveapplicationaccept.ts
Normal file
14
src/components/buttons/inactiveapplicationaccept.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "inactiveapplicationaccept",
|
||||
description: "Accept an inactivity application.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.reply({
|
||||
content: "This button is currently disabled.",
|
||||
ephemeral: true,
|
||||
})
|
||||
},
|
||||
} as Button
|
||||
14
src/components/buttons/inactiveapplicationdeny.ts
Normal file
14
src/components/buttons/inactiveapplicationdeny.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "inactiveapplicationdeny",
|
||||
description: "Denies an inactivity application.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.reply({
|
||||
content: "This button is currently disabled.",
|
||||
ephemeral: true,
|
||||
})
|
||||
},
|
||||
} as Button
|
||||
72
src/components/buttons/staffapplicationaccept.ts
Normal file
72
src/components/buttons/staffapplicationaccept.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"
|
||||
import { color } from "../../../config/options.json"
|
||||
import staffapp from "../../schemas/staffAppSchema"
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "staffapplicationaccept",
|
||||
description: "Accept a staff application.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.user
|
||||
const guild = interaction.guild!
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer!.text.split(" ")[1]
|
||||
|
||||
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 staff team has been accepted.",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true),
|
||||
),
|
||||
],
|
||||
})
|
||||
|
||||
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()!,
|
||||
text: "ID: " + applicantId,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
},
|
||||
} as Button
|
||||
32
src/components/buttons/staffapplicationdeny.ts
Normal file
32
src/components/buttons/staffapplicationdeny.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
ModalBuilder,
|
||||
ActionRowBuilder,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js"
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "staffapplicationdeny",
|
||||
description: "Deny a guild application.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
const modal = new ModalBuilder()
|
||||
.setTitle("Deny Reason")
|
||||
.setCustomId("staffdenyreasonbox")
|
||||
.setComponents(
|
||||
new ActionRowBuilder<TextInputBuilder>().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)
|
||||
},
|
||||
} as Button
|
||||
528
src/components/buttons/staffapply.ts
Normal file
528
src/components/buttons/staffapply.ts
Normal file
@@ -0,0 +1,528 @@
|
||||
import {
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
ActionRowBuilder,
|
||||
EmbedBuilder,
|
||||
GuildMember,
|
||||
GuildTextBasedChannel,
|
||||
} from "discord.js"
|
||||
import { color, staffApplicationsChannel } from "../../../config/options.json"
|
||||
import { largeM, ignM } from "../../../config/limitmessages.json"
|
||||
import questions from "../../../config/questions.json"
|
||||
import { guildRole, guildStaff } from "../../../config/roles.json"
|
||||
import mongoose from "mongoose"
|
||||
import staffapp from "../../schemas/staffAppSchema"
|
||||
import settings from "../../schemas/settingsSchema"
|
||||
import { getUUID } from "../../utils/Hypixel"
|
||||
import { Button } from "../../interfaces"
|
||||
import env from "../../utils/Env"
|
||||
|
||||
export = {
|
||||
name: "staffapply",
|
||||
description: "Apply for the staff team.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
const user = interaction.member as GuildMember
|
||||
const guild = interaction.guild!
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
const userRoles = user.roles.cache
|
||||
const setting = await settings.findOne({ name: "staffAppStatus" })
|
||||
const status = setting!.value || "0"
|
||||
const staffQuestions = questions.staff
|
||||
|
||||
function sq(n: number): string {
|
||||
return staffQuestions[n - 1].q
|
||||
}
|
||||
|
||||
function rq(n: number): string {
|
||||
return staffQuestions[n - 1].r
|
||||
}
|
||||
|
||||
if (interaction.customId === "staffapply") {
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
if (user.user.id !== env.prod.dev) {
|
||||
if (status === "0") {
|
||||
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.",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (userRoles.has(guildStaff)) {
|
||||
await interaction.editReply("You are already a staff member.")
|
||||
return
|
||||
}
|
||||
|
||||
const application = await staffapp.findOne({ userID: user.user.id })
|
||||
|
||||
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)
|
||||
|
||||
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("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
|
||||
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.",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
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
|
||||
|
||||
// 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.",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
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 > 64) {
|
||||
await user.send({
|
||||
embeds: [
|
||||
{
|
||||
description: "Max character limit is 64.",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
const answer2_1 = answer2.first()!.content
|
||||
|
||||
// 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.",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
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 > 256) {
|
||||
await user.send({
|
||||
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.",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
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:
|
||||
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,
|
||||
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 > 256) {
|
||||
await user.send({
|
||||
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.",
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
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
|
||||
|
||||
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 newStaffApp = new staffapp({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: user.user.id,
|
||||
uuid: uuid,
|
||||
})
|
||||
|
||||
await newStaffApp.save()
|
||||
await user.deleteDM()
|
||||
|
||||
const channel = guild.channels.cache.get(
|
||||
staffApplicationsChannel,
|
||||
) as GuildTextBasedChannel
|
||||
|
||||
await channel.send({
|
||||
embeds: [
|
||||
{
|
||||
title:
|
||||
user.user.username +
|
||||
"#" +
|
||||
user.user.discriminator +
|
||||
" - Staff Application",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: user.avatarURL() || guild.iconURL()!,
|
||||
},
|
||||
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()!,
|
||||
text: "ID: " + user.user.id,
|
||||
},
|
||||
},
|
||||
],
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
),
|
||||
],
|
||||
})
|
||||
}
|
||||
},
|
||||
} as Button
|
||||
32
src/components/buttons/verify.ts
Normal file
32
src/components/buttons/verify.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
ModalBuilder,
|
||||
ActionRowBuilder,
|
||||
TextInputBuilder,
|
||||
TextInputStyle,
|
||||
} from "discord.js"
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "verify",
|
||||
description: "Configure the bot.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
const modal = new ModalBuilder()
|
||||
.setTitle("Verification")
|
||||
.setCustomId("verifybox")
|
||||
.setComponents(
|
||||
new ActionRowBuilder<TextInputBuilder>().setComponents(
|
||||
new TextInputBuilder()
|
||||
.setLabel("IGN")
|
||||
.setCustomId("verifyign")
|
||||
.setStyle(TextInputStyle.Short)
|
||||
.setPlaceholder("Enter your ign.")
|
||||
.setRequired(true)
|
||||
.setMinLength(3)
|
||||
.setMaxLength(16),
|
||||
),
|
||||
)
|
||||
await interaction.showModal(modal)
|
||||
},
|
||||
} as Button
|
||||
59
src/components/buttons/waitingListUpdate.ts
Normal file
59
src/components/buttons/waitingListUpdate.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import waitinglist from "../../schemas/waitinglistSchema"
|
||||
import { getGuild } from "../../utils/Hypixel"
|
||||
import { hypixelGuildID } from "../../../config/options.json"
|
||||
import { Button } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "waitinglistupdate",
|
||||
description: "Update the waiting list.",
|
||||
type: "button",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
const user = interaction.user
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const accepted = await waitinglist.find()
|
||||
|
||||
for (let i = 0; i < accepted.length; i++) {
|
||||
const uuid = accepted[i].uuid
|
||||
const guild = await getGuild(uuid)
|
||||
|
||||
if (guild && guild._id === hypixelGuildID) {
|
||||
await waitinglist.findOneAndDelete({ uuid: uuid })
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const fields = []
|
||||
|
||||
for (let i = 0; i < accepted.length; i++) {
|
||||
const timestamp = Math.floor(accepted[i].timestamp / 1000)
|
||||
|
||||
fields.push({
|
||||
name: `${i + 1}. ${accepted[i].IGN}`,
|
||||
value: `TS: <t:${timestamp}:R>`,
|
||||
})
|
||||
}
|
||||
|
||||
await message.edit({
|
||||
embeds: [
|
||||
{
|
||||
title: embed.title!,
|
||||
description: embed.description!,
|
||||
color: embed.color!,
|
||||
footer: {
|
||||
text: "Last updated by " + user.username,
|
||||
icon_url: user.avatarURL()!,
|
||||
},
|
||||
thumbnail: embed.thumbnail!,
|
||||
fields: fields,
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await interaction.editReply("Updated the waiting list")
|
||||
},
|
||||
} as Button
|
||||
109
src/components/modals/denyreasonbox.ts
Normal file
109
src/components/modals/denyreasonbox.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import {
|
||||
EmbedBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
Message,
|
||||
GuildMember,
|
||||
} from "discord.js"
|
||||
import { color } from "../../../config/options.json"
|
||||
import guildapp from "../../schemas/guildAppSchema"
|
||||
import { Modal } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "denyreasonbox",
|
||||
description: "Deny reason box.",
|
||||
type: "modal",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply()
|
||||
|
||||
const guild = interaction.guild!
|
||||
const message = interaction.message as Message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer!.text.split(" ")[1]
|
||||
|
||||
const reason =
|
||||
interaction.fields.fields.get("denyreason")!.value ||
|
||||
"No reason provided"
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>().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),
|
||||
),
|
||||
],
|
||||
})
|
||||
|
||||
let applicant: GuildMember | null
|
||||
try {
|
||||
applicant = await guild.members.fetch(applicantId)
|
||||
} catch (error) {
|
||||
applicant = null
|
||||
}
|
||||
|
||||
const dmMessage = new EmbedBuilder()
|
||||
.setDescription(
|
||||
"Your application for the Illegitimate guild has been denied\n" +
|
||||
"**Reason:** `" +
|
||||
reason +
|
||||
"`",
|
||||
)
|
||||
.setColor(embedColor)
|
||||
|
||||
const missingUser = new EmbedBuilder()
|
||||
.setDescription(
|
||||
"[WARN] User has left the server and cannot be notified.",
|
||||
)
|
||||
.setColor(embedColor)
|
||||
|
||||
const responseEmbed = new EmbedBuilder()
|
||||
.setTitle("Application Denied")
|
||||
.setDescription(
|
||||
"The application has been denied by <@" +
|
||||
interaction.user.id +
|
||||
">.\n" +
|
||||
"**Reason:** `" +
|
||||
reason +
|
||||
"`",
|
||||
)
|
||||
.setColor(embedColor)
|
||||
.setThumbnail(guild.iconURL())
|
||||
.setFooter({
|
||||
iconURL: guild.iconURL()!,
|
||||
text: "ID: " + applicantId,
|
||||
})
|
||||
|
||||
if (applicant !== null) {
|
||||
await applicant.send({ embeds: [dmMessage] })
|
||||
}
|
||||
|
||||
let responseEmbeds: EmbedBuilder[]
|
||||
if (applicant === null) {
|
||||
responseEmbeds = [responseEmbed, missingUser]
|
||||
} else {
|
||||
responseEmbeds = [responseEmbed]
|
||||
}
|
||||
|
||||
await guildapp.findOneAndDelete({ userID: applicantId })
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: responseEmbeds,
|
||||
})
|
||||
},
|
||||
} as Modal
|
||||
83
src/components/modals/staffdenyreasonbox.ts
Normal file
83
src/components/modals/staffdenyreasonbox.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import {
|
||||
EmbedBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
} from "discord.js"
|
||||
import { color } from "../../../config/options.json"
|
||||
import staffapp from "../../schemas/staffAppSchema"
|
||||
import { Modal } from "../../interfaces"
|
||||
|
||||
export = {
|
||||
name: "staffdenyreasonbox",
|
||||
description: "Deny reason box.",
|
||||
type: "modal",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply()
|
||||
|
||||
const guild = interaction.guild
|
||||
const reason =
|
||||
interaction.fields.fields.get("staffdenyreason")!.value ||
|
||||
"No reason provided"
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = interaction.message!
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer!.text.split(" ")[1]
|
||||
const applicant = await guild!.members.fetch(applicantId)
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true),
|
||||
),
|
||||
],
|
||||
})
|
||||
|
||||
const dmMessage = new EmbedBuilder()
|
||||
.setDescription(
|
||||
"Your application for the Illegitimate guild staff has been denied\n" +
|
||||
"**Reason:** `" +
|
||||
reason +
|
||||
"`",
|
||||
)
|
||||
.setColor(embedColor)
|
||||
|
||||
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() || guild!.iconURL()!,
|
||||
},
|
||||
footer: {
|
||||
icon_url: guild!.iconURL()!,
|
||||
text: "ID: " + applicant.id,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
},
|
||||
} as Modal
|
||||
195
src/components/modals/verifyModal.ts
Normal file
195
src/components/modals/verifyModal.ts
Normal file
@@ -0,0 +1,195 @@
|
||||
import { getUUID, getPlayer, getGuild, getHeadURL } from "../../utils/Hypixel"
|
||||
import { color, hypixelGuildID, devMessage } from "../../../config/options.json"
|
||||
import verify from "../../schemas/verifySchema"
|
||||
import mongoose from "mongoose"
|
||||
import {
|
||||
gm,
|
||||
manager,
|
||||
moderator,
|
||||
beast,
|
||||
elite,
|
||||
member,
|
||||
guildRole,
|
||||
guildStaff,
|
||||
defaultMember,
|
||||
} from "../../../config/roles.json"
|
||||
import { Modal } from "../../interfaces"
|
||||
import { GuildMember } from "discord.js"
|
||||
|
||||
export = {
|
||||
name: "verifybox",
|
||||
description: "Verify box.",
|
||||
type: "modal",
|
||||
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
const user = interaction.member as GuildMember
|
||||
const ign = interaction.fields.fields.get("verifyign")!.value
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const verifyData = await verify.findOne({ userID: user.user.id })
|
||||
if (verifyData) {
|
||||
interaction.editReply(
|
||||
"You are already verified.\n" +
|
||||
"Try running /update to update your roles.",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const uuid = await getUUID(ign)
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description:
|
||||
"<a:questionmark_pink:1130206038008803488> That player does not exist.",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description:
|
||||
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let username = ""
|
||||
if (user.user.discriminator === "0") {
|
||||
username = user.user.username
|
||||
} else {
|
||||
username = user.user.username + "#" + user.user.discriminator
|
||||
}
|
||||
|
||||
const linkedDiscord = player?.socialMedia?.links?.DISCORD
|
||||
if (!linkedDiscord) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description:
|
||||
"<a:cross_a:1087808606897983539> There is no Discord account linked to `" +
|
||||
player.displayname +
|
||||
"`.\n\n" +
|
||||
"**Please set your Discord tag on hypixel to `" +
|
||||
username +
|
||||
"` and try again.**",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (linkedDiscord !== username) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description:
|
||||
"<a:cross_a:1087808606897983539> The Discord account linked to `" +
|
||||
player.displayname +
|
||||
"` is currently `" +
|
||||
linkedDiscord +
|
||||
"`\n\n" +
|
||||
"**Please set your Discord tag on hypixel to `" +
|
||||
username +
|
||||
"` and try again.**",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
let guildID: string | null
|
||||
if (!guild) {
|
||||
guildID = null
|
||||
} else {
|
||||
guildID = guild._id
|
||||
}
|
||||
|
||||
if (guildID === hypixelGuildID) {
|
||||
const GuildMembers = guild!.members
|
||||
const guildRank = GuildMembers.find(
|
||||
member => member.uuid === player.uuid,
|
||||
)!.rank
|
||||
|
||||
if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(gm, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
await user.roles.add(guildStaff, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Manager" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(manager, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
await user.roles.add(guildStaff, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Moderator" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(moderator, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
await user.roles.add(guildStaff, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Beast" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(beast, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Elite" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(elite, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Member" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(member, "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: uuid,
|
||||
})
|
||||
|
||||
await newVerify.save()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
title: interaction.guild!.name,
|
||||
description:
|
||||
"You have successfully verified `" +
|
||||
username +
|
||||
"` with the account `" +
|
||||
player.displayname +
|
||||
"`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head!,
|
||||
},
|
||||
footer: {
|
||||
icon_url: interaction.guild!.iconURL()!,
|
||||
text: interaction.guild!.name + " | " + devMessage,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
},
|
||||
} as Modal
|
||||
Reference in New Issue
Block a user