Updated buttons and etc to components folder

This commit is contained in:
2024-01-03 19:52:17 +01:00
parent 1efecbc5a2
commit c566b0c632
19 changed files with 3 additions and 3 deletions

View 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

View 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

View 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