Merge branch 'dev' into 'main'

Dev

See merge request illegitimate/illegitimate-bot!232
This commit is contained in:
2024-02-20 12:20:31 +00:00
8 changed files with 107 additions and 28 deletions

80
src/commands/find.ts Normal file
View File

@@ -0,0 +1,80 @@
import { devMessage, embedColor } from "config/options"
import { PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
import { ICommand } from "interfaces"
import verifySchema from "schemas/verifySchema"
import { getHeadURL, getIGN, getUUID } from "utils/Hypixel"
export = {
name: "find",
description: "Find a person by the ign",
dev: false,
public: false,
data: new SlashCommandBuilder()
.setName("find")
.setDescription("Find a person by the ign")
.addStringOption(option =>
option
.setName("ign")
.setDescription("The ign to lookup.")
.setRequired(true)
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const ign = interaction.options.getString("ign")!
const uuid = await getUUID(ign)
if (!uuid) {
await interaction.editReply({
embeds: [{
description: "No minecraft account found with the ign " + ign,
color: embedColor
}]
})
return
}
const verifyData = await verifySchema.findOne({ uuid: uuid })
if (!verifyData) {
await interaction.editReply({
embeds: [{
description: "No user found with the ign " + ign,
color: embedColor
}]
})
return
}
const user = await interaction.guild?.members.fetch(verifyData.userID)
if (!user) {
await interaction.editReply({
embeds: [{
description: "User is not in the server.",
color: embedColor
}]
})
return
}
const head = await getHeadURL(ign)
const formattedIgn = await getIGN(uuid)
await interaction.editReply({
embeds: [{
title: interaction.guild!.name,
description: "**User:** " + userMention(user.user.id) +
"\n**IGN:** " + formattedIgn,
color: embedColor,
thumbnail: {
url: head!
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
})
}
} as ICommand

View File

@@ -151,11 +151,7 @@ export = {
replyRank = "Member" replyRank = "Member"
} }
// FIXME: need to check if user is on waiting list await user.roles.remove(waitingListRole, "User was force updated.")
if (user.roles.cache.has(waitingListRole)) {
await user.roles.remove(waitingListRole, "User was force updated.")
}
await user.setNickname(ign, "User was force updated.").catch(() => { await user.setNickname(ign, "User was force updated.").catch(() => {
// Do nothing // Do nothing
}) })

View File

@@ -1,13 +1,14 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js" import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
import { embedColor, devMessage } from "config/options" import { embedColor, devMessage } from "config/options"
import waitinglistSchema from "schemas/waitinglistSchema" import waitinglistSchema from "schemas/waitinglistSchema"
import { ICommand } from "interfaces" import { ICommand } from "interfaces"
import logToChannel from "utils/functions/logtochannel" import logToChannel from "utils/functions/logtochannel"
import { waitingListRole } from "config/roles"
export = { export = {
name: "remove", name: "remove",
description: "Remove a person on the waiting list.", description: "Remove a person on the waiting list.",
false: true, dev: false,
public: false, public: false,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@@ -31,22 +32,23 @@ export = {
async execute(interaction) { async execute(interaction) {
await interaction.deferReply() await interaction.deferReply()
const user = interaction.options.getUser("user")! const member = interaction.options.getMember("user") as GuildMember
const reason = interaction.options.getString("reason") ?? "No reason provided." const reason = interaction.options.getString("reason") ?? "No reason provided."
const mod = interaction.user! const mod = interaction.user!
const waitinglist = await waitinglistSchema.findOne({ userID: user.id }) const waitinglist = await waitinglistSchema.findOne({ userID: member.user.id })
if (!waitinglist) { if (!waitinglist) {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [{
description: userMention(user.id) + " is not on the waiting list.", description: userMention(member.user.id) + " is not on the waiting list.",
color: embedColor color: embedColor
}] }]
}) })
return return
} }
await waitinglistSchema.findOneAndDelete({ userID: user.id }) await waitinglistSchema.findOneAndDelete({ userID: member.user.id })
await member.roles.remove(waitingListRole, "Removed from waiting list.")
await logToChannel("mod", { await logToChannel("mod", {
embeds: [{ embeds: [{
@@ -56,7 +58,7 @@ export = {
}, },
title: "Waiting List - Remove User", title: "Waiting List - Remove User",
description: ` description: `
**User:** ${userMention(user.id)} **User:** ${userMention(member.user.id)}
**Reason:** ${reason} **Reason:** ${reason}
**Mod:** ${userMention(mod.id)} **Mod:** ${userMention(mod.id)}
`, `,
@@ -65,8 +67,8 @@ export = {
url: mod.avatarURL() || "" url: mod.avatarURL() || ""
}, },
footer: { footer: {
icon_url: user.avatarURL() || undefined, icon_url: member.avatarURL() || undefined,
text: "ID: " + user.id text: "ID: " + member.user.id
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString()
}] }]
@@ -75,7 +77,7 @@ export = {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [{
title: "Waiting List - Remove User", title: "Waiting List - Remove User",
description: "**User:** " + userMention(user.id) + "\n" + description: "**User:** " + userMention(member.user.id) + "\n" +
"**Reason:** `" + reason + "`", "**Reason:** `" + reason + "`",
color: embedColor, color: embedColor,
footer: { footer: {

View File

@@ -134,10 +134,7 @@ export = {
replyRank = "Member" replyRank = "Member"
} }
// FIXME: need to check if user is on waiting list await user.roles.remove(waitingListRole, "User used the update command")
if (user.roles.cache.has(waitingListRole)) {
await user.roles.remove(waitingListRole, "User used the update command")
}
await user.setNickname(ign, "Verification").catch(() => { await user.setNickname(ign, "Verification").catch(() => {
// Do nothing // Do nothing

View File

@@ -28,7 +28,12 @@ export = {
const user = interaction.options.getUser("user")! const user = interaction.options.getUser("user")!
const verifiedUser = await verify.findOne({ userID: user.id }) const verifiedUser = await verify.findOne({ userID: user.id })
if (!verifiedUser) { if (!verifiedUser) {
interaction.editReply("You are not verified!") interaction.editReply({
embeds: [{
description: userMention(user.id) + " is not verified.",
color: embedColor
}]
})
return return
} }

View File

@@ -6,7 +6,7 @@ import guildapp from "schemas/guildAppSchema"
import waitingList from "schemas/waitinglistSchema" import waitingList from "schemas/waitinglistSchema"
import { waitingListRole } from "config/roles" import { waitingListRole } from "config/roles"
import { IButton } from "interfaces" import { IButton } from "interfaces"
import { getGuild } from "utils/Hypixel" import { getGuild, getIGN } from "utils/Hypixel"
export = { export = {
name: "guildapplicationaccept", name: "guildapplicationaccept",
@@ -20,7 +20,6 @@ export = {
const message = interaction.message const message = interaction.message
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 applicantIGN = embed.fields[0].value.replaceAll("`", "")
const applicant = await guild.members.fetch(applicantId) const applicant = await guild.members.fetch(applicantId)
const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator
@@ -63,7 +62,6 @@ export = {
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: applicantId, userID: applicantId,
uuid: applicantUUID, uuid: applicantUUID,
IGN: applicantIGN,
timestamp: time timestamp: time
}) })
@@ -108,10 +106,11 @@ export = {
const fields: { name: string; value: string }[] = [] const fields: { name: string; value: string }[] = []
for (let i = 0; i < accepted.length; i++) { for (let i = 0; i < accepted.length; i++) {
const ign = await getIGN(accepted[i].uuid)
const timestamp = Math.floor(accepted[i].timestamp / 1000) const timestamp = Math.floor(accepted[i].timestamp / 1000)
fields.push({ fields.push({
name: `${i + 1}. ${accepted[i].IGN}`, name: `${i + 1}. ${ign}`,
value: `TS: <t:${timestamp}:R>` value: `TS: <t:${timestamp}:R>`
}) })
} }

View File

@@ -1,5 +1,5 @@
import waitinglist from "schemas/waitinglistSchema" import waitinglist from "schemas/waitinglistSchema"
import { getGuild } from "utils/Hypixel" import { getGuild, getIGN } from "utils/Hypixel"
import { hypixelGuildID } from "config/options" import { hypixelGuildID } from "config/options"
import { IButton } from "interfaces" import { IButton } from "interfaces"
@@ -28,10 +28,11 @@ export = {
const fields = [] const fields = []
for (let i = 0; i < accepted.length; i++) { for (let i = 0; i < accepted.length; i++) {
const ign = await getIGN(accepted[i].uuid)
const timestamp = Math.floor(accepted[i].timestamp / 1000) const timestamp = Math.floor(accepted[i].timestamp / 1000)
fields.push({ fields.push({
name: `${i + 1}. ${accepted[i].IGN}`, name: `${i + 1}. ${ign}`,
value: `TS: <t:${timestamp}:R>` value: `TS: <t:${timestamp}:R>`
}) })
} }

View File

@@ -4,7 +4,6 @@ const waitinglistSchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
userID: { type: String, required: true }, userID: { type: String, required: true },
uuid: { type: String, required: true }, uuid: { type: String, required: true },
IGN: { type: String, required: true },
timestamp: { type: Number, required: true } timestamp: { type: Number, required: true }
}) })