Updated guild application accept
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
waitingListMessage,
|
||||
hypixelGuildID,
|
||||
} from "../../../config/options.json"
|
||||
import colorLog from "../../utils/functions/colors"
|
||||
import mongoose from "mongoose"
|
||||
import guildapp from "../../schemas/guildAppSchema"
|
||||
import waitingList from "../../schemas/waitinglistSchema"
|
||||
@@ -88,53 +89,6 @@ export = {
|
||||
await applicant.roles.add(waitingListRole)
|
||||
await guildapp.findOneAndDelete({ userID: applicantId })
|
||||
|
||||
// update waiting list
|
||||
const channel = guild.channels.cache.get(
|
||||
waitingListChannel,
|
||||
) as TextChannel
|
||||
const wlmessage = await channel!.messages.fetch(waitingListMessage)
|
||||
|
||||
const wlembed = wlmessage.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: { name: string; value: string }[] = []
|
||||
|
||||
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 wlmessage.edit({
|
||||
embeds: [
|
||||
{
|
||||
title: wlembed.title!,
|
||||
description: wlembed.description!,
|
||||
color: wlembed.color!,
|
||||
footer: {
|
||||
text: "Last updated by " + user.username,
|
||||
icon_url: user.avatarURL() || undefined,
|
||||
},
|
||||
thumbnail: wlembed.thumbnail!,
|
||||
fields: fields,
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
@@ -152,5 +106,56 @@ export = {
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
try {
|
||||
const channel = guild.channels.cache.get(
|
||||
waitingListChannel,
|
||||
) as TextChannel
|
||||
const wlmessage = await channel!.messages.fetch(waitingListMessage)
|
||||
|
||||
const wlembed = wlmessage.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: { name: string; value: string }[] = []
|
||||
|
||||
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 wlmessage.edit({
|
||||
embeds: [
|
||||
{
|
||||
title: wlembed.title!,
|
||||
description: wlembed.description!,
|
||||
color: wlembed.color!,
|
||||
footer: {
|
||||
text: "Last updated by " + user.username,
|
||||
icon_url: user.avatarURL() || undefined,
|
||||
},
|
||||
thumbnail: wlembed.thumbnail!,
|
||||
fields: fields,
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(colorLog("Error while trying to update waiting list.", "red"))
|
||||
}
|
||||
},
|
||||
} as Button
|
||||
|
||||
Reference in New Issue
Block a user