Updated formatting on modals and autocomplete

This commit is contained in:
2024-01-20 17:34:25 +01:00
parent e60523c7b6
commit 631581574c
4 changed files with 60 additions and 146 deletions

View File

@@ -9,21 +9,15 @@ export = {
if (focusedOption.name !== "user") return if (focusedOption.name !== "user") return
if (focusedOption.value === "") { if (focusedOption.value === "") {
await interaction.respond([ await interaction.respond([{
{ name: "Please start typing a username to unban",
name: "Please start typing a username to unban", value: "none"
value: "none" }])
}
])
return return
} }
const bannedUsers = await interaction.guild!.bans.fetch() const bannedUsers = await interaction.guild!.bans.fetch()
const filteredUsers = bannedUsers.filter(user => const filteredUsers = bannedUsers.filter(user => user.user.username.toLowerCase().includes(focusedOption.value.toLowerCase()))
user.user.username
.toLowerCase()
.includes(focusedOption.value.toLowerCase())
)
const results = filteredUsers.map(user => ({ const results = filteredUsers.map(user => ({
name: user.user.username, name: user.user.username,

View File

@@ -1,11 +1,4 @@
import { import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Message, GuildMember } from "discord.js"
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Message,
GuildMember
} from "discord.js"
import { color } from "config/options.json" import { color } from "config/options.json"
import guildapp from "schemas/guildAppSchema" import guildapp from "schemas/guildAppSchema"
import { Modal } from "interfaces" import { Modal } from "interfaces"
@@ -22,9 +15,7 @@ export = {
const embed = message.embeds[0] const embed = message.embeds[0]
const applicantId = embed.footer!.text.split(" ")[1] const applicantId = embed.footer!.text.split(" ")[1]
const reason = const reason = interaction.fields.fields.get("denyreason")!.value || "No reason provided"
interaction.fields.fields.get("denyreason")!.value ||
"No reason provided"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
await message.edit({ await message.edit({
@@ -57,29 +48,19 @@ export = {
} }
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription( .setDescription("Your application for the Illegitimate guild has been denied\n" +
"Your application for the Illegitimate guild has been denied\n" + "**Reason:** `" + reason + "`"
"**Reason:** `" +
reason +
"`"
) )
.setColor(embedColor) .setColor(embedColor)
const missingUser = new EmbedBuilder() const missingUser = new EmbedBuilder()
.setDescription( .setDescription("[WARN] User has left the server and cannot be notified.")
"[WARN] User has left the server and cannot be notified."
)
.setColor(embedColor) .setColor(embedColor)
const responseEmbed = new EmbedBuilder() const responseEmbed = new EmbedBuilder()
.setTitle("Application Denied") .setTitle("Application Denied")
.setDescription( .setDescription("The application has been denied by <@" + interaction.user.id + ">.\n" +
"The application has been denied by <@" + "**Reason:** `" + reason + "`"
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`"
) )
.setColor(embedColor) .setColor(embedColor)
.setThumbnail(guild.iconURL() || "") .setThumbnail(guild.iconURL() || "")

View File

@@ -1,9 +1,4 @@
import { import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle
} from "discord.js"
import { color } from "config/options.json" import { color } from "config/options.json"
import staffapp from "schemas/staffAppSchema" import staffapp from "schemas/staffAppSchema"
import { Modal } from "interfaces" import { Modal } from "interfaces"
@@ -16,9 +11,7 @@ export = {
await interaction.deferReply() await interaction.deferReply()
const guild = interaction.guild const guild = interaction.guild
const reason = const reason = interaction.fields.fields.get("staffdenyreason")!.value || "No reason provided"
interaction.fields.fields.get("staffdenyreason")!.value ||
"No reason provided"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const message = interaction.message! const message = interaction.message!
@@ -44,11 +37,8 @@ export = {
}) })
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription( .setDescription("Your application for the Illegitimate guild staff has been denied\n" +
"Your application for the Illegitimate guild staff has been denied\n" + "**Reason:** `" + reason + "`"
"**Reason:** `" +
reason +
"`"
) )
.setColor(embedColor) .setColor(embedColor)
@@ -57,26 +47,19 @@ export = {
await staffapp.findOneAndDelete({ userID: applicantId }) await staffapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "Application Denied",
title: "Application Denied", description: "The application has been denied by <@" + interaction.user.id + ">.\n" +
description: "**Reason:** `" + reason + "`",
"The application has been denied by <@" + color: embedColor,
interaction.user.id + thumbnail: {
">.\n" + url: applicant.avatarURL() || ""
"**Reason:** `" + },
reason + footer: {
"`", icon_url: guild!.iconURL() || undefined,
color: embedColor, text: "ID: " + applicant.id
thumbnail: {
url: applicant.avatarURL() || ""
},
footer: {
icon_url: guild!.iconURL() || undefined,
text: "ID: " + applicant.id
}
} }
] }]
}) })
} }
} as Modal } as Modal

View File

@@ -2,17 +2,7 @@ import { getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
import { color, hypixelGuildID, devMessage } from "config/options.json" import { color, hypixelGuildID, devMessage } from "config/options.json"
import verify from "schemas/verifySchema" import verify from "schemas/verifySchema"
import mongoose from "mongoose" import mongoose from "mongoose"
import { import { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "config/roles.json"
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember
} from "config/roles.json"
import { Modal } from "interfaces" import { Modal } from "interfaces"
import { GuildMember } from "discord.js" import { GuildMember } from "discord.js"
@@ -29,23 +19,17 @@ export = {
const verifyData = await verify.findOne({ userID: user.user.id }) const verifyData = await verify.findOne({ userID: user.user.id })
if (verifyData) { if (verifyData) {
interaction.editReply( interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
"You are already verified.\n" +
"Try running /update to update your roles."
)
return return
} }
const uuid = await getUUID(ign) const uuid = await getUUID(ign)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player does not exist.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player does not exist.", }]
color: embedColor
}
]
}) })
return return
} }
@@ -54,13 +38,10 @@ export = {
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.", }]
color: embedColor
}
]
}) })
return return
} }
@@ -75,38 +56,22 @@ export = {
const linkedDiscord = player?.socialMedia?.links?.DISCORD const linkedDiscord = player?.socialMedia?.links?.DISCORD
if (!linkedDiscord) { if (!linkedDiscord) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + player.displayname + "`.\n\n" +
description: "**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
"<a:cross_a:1087808606897983539> There is no Discord account linked to `" + color: embedColor
player.displayname + }]
"`.\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor
}
]
}) })
return return
} }
if (linkedDiscord !== username) { if (linkedDiscord !== username) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:cross_a:1087808606897983539> The Discord account linked to `" + player.displayname + "` is currently `" + linkedDiscord + "`\n\n" +
description: "**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
"<a:cross_a:1087808606897983539> The Discord account linked to `" + color: embedColor
player.displayname + }]
"` is currently `" +
linkedDiscord +
"`\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor
}
]
}) })
return return
} }
@@ -121,9 +86,7 @@ export = {
if (guildID === hypixelGuildID) { if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find( const guildRank = GuildMembers.find(member => member.uuid === player.uuid)!.rank
member => member.uuid === player.uuid
)!.rank
if (guildRank === "Guild Master" && guildID === hypixelGuildID) { if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
await user.roles.add(gm, "Verification") await user.roles.add(gm, "Verification")
@@ -169,25 +132,18 @@ export = {
await newVerify.save() await newVerify.save()
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: interaction.guild!.name,
title: interaction.guild!.name, description: "You have successfully verified `" + username + "` with the account `" + player.displayname + "`.",
description: color: embedColor,
"You have successfully verified `" + thumbnail: {
username + url: head!
"` with the account `" + },
player.displayname + footer: {
"`.", icon_url: interaction.guild!.iconURL() || undefined,
color: embedColor, text: interaction.guild!.name + " | " + devMessage
thumbnail: {
url: head!
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
} }
] }]
}) })
} }
} }