Moved from mongodb to sql and sqlite
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { embedColor, devMessage } from "config/options"
|
||||
import guildapp from "schemas/guildAppSchema"
|
||||
import guildapp from "schemas/guildAppTag"
|
||||
import { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "config/reqs"
|
||||
import { hypixelLevel, bedwarsLevel, skywarsLevel, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
|
||||
import { IButton } from "interfaces"
|
||||
@@ -14,7 +14,7 @@ export = {
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer!.text.split(" ")[1]
|
||||
const guildappdata = await guildapp.findOne({ userID: applicantId })
|
||||
const guildappdata = await guildapp.findOne({ where: { userID: applicantId } })
|
||||
const uuid = guildappdata!.uuid
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { ActionRowBuilder, ButtonStyle, ButtonBuilder, TextChannel } from "discord.js"
|
||||
import { embedColor, waitingListChannel, waitingListMessage, hypixelGuildID } from "config/options"
|
||||
import color from "utils/functions/colors"
|
||||
import mongoose from "mongoose"
|
||||
import guildapp from "schemas/guildAppSchema"
|
||||
import waitingList from "schemas/waitinglistSchema"
|
||||
import guildapp from "schemas/guildAppTag"
|
||||
import waitingList from "schemas/waitinglistTag"
|
||||
import { waitingListRole } from "config/roles"
|
||||
import { IButton } from "interfaces"
|
||||
import { getGuild, getIGN } from "utils/Hypixel"
|
||||
@@ -54,21 +53,18 @@ export = {
|
||||
}]
|
||||
})
|
||||
|
||||
const applicantEntry = await guildapp.findOne({ userID: applicantId })
|
||||
const applicantEntry = await guildapp.findOne({ where: { userID: applicantId } })
|
||||
const applicantUUID = applicantEntry!.uuid
|
||||
const time = Date.now()
|
||||
|
||||
const waitingListAdd = new waitingList({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
await waitingList.create({
|
||||
userID: applicantId,
|
||||
uuid: applicantUUID,
|
||||
timestamp: time
|
||||
})
|
||||
|
||||
await waitingListAdd.save()
|
||||
|
||||
await applicant.roles.add(waitingListRole)
|
||||
await guildapp.findOneAndDelete({ userID: applicantId })
|
||||
await applicantEntry?.destroy()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
@@ -91,14 +87,14 @@ export = {
|
||||
const wlmessage = await channel!.messages.fetch(waitingListMessage)
|
||||
|
||||
const wlembed = wlmessage.embeds[0]
|
||||
const accepted = await waitingList.find()
|
||||
const accepted = await waitingList.findAll()
|
||||
|
||||
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 })
|
||||
await waitingList.destroy({ where: { uuid: uuid } })
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ import { embedColor, applicationsChannel } from "config/options"
|
||||
import { largeM, smallM, ignM } from "config/limitmessages"
|
||||
import questions from "config/questions"
|
||||
import { guildRole } from "config/roles"
|
||||
import mongoose from "mongoose"
|
||||
import guildapp from "schemas/guildAppSchema"
|
||||
import guildapp from "schemas/guildAppTag"
|
||||
import { IButton } from "interfaces"
|
||||
import applicationQuestions from "utils/functions/applicationquestions"
|
||||
|
||||
@@ -32,7 +31,7 @@ export = {
|
||||
return
|
||||
}
|
||||
|
||||
const application = await guildapp.findOne({ userID: user.user.id })
|
||||
const application = await guildapp.findOne({ where: { userID: user.user.id } })
|
||||
|
||||
if (application) {
|
||||
await interaction.editReply("You already have an application in progress.")
|
||||
@@ -249,14 +248,11 @@ export = {
|
||||
}]
|
||||
})
|
||||
|
||||
const newGuildApp = new guildapp({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
await guildapp.create({
|
||||
userID: user.user.id,
|
||||
uuid: uuid
|
||||
uuid: uuid,
|
||||
})
|
||||
|
||||
await newGuildApp.save()
|
||||
|
||||
const channel = guild.channels.cache.get(applicationsChannel) as TextChannel
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
|
||||
@@ -17,10 +17,11 @@ export = {
|
||||
const userRoles = user.roles.cache
|
||||
|
||||
if (!userRoles.some(role => guildRoles.includes(role.id))) {
|
||||
return await interaction.reply({
|
||||
await interaction.reply({
|
||||
content: "Only guild members can use this button.",
|
||||
ephemeral: true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
function sq(n: number): string {
|
||||
@@ -44,10 +45,11 @@ export = {
|
||||
}]
|
||||
})
|
||||
} catch (error) {
|
||||
return await interaction.reply({
|
||||
await interaction.reply({
|
||||
content: "Please enable your DMs.",
|
||||
ephemeral: true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.reply({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"
|
||||
import { embedColor } from "config/options"
|
||||
import staffapp from "schemas/staffAppSchema"
|
||||
import staffapp from "schemas/staffAppTag"
|
||||
import { IButton } from "interfaces"
|
||||
|
||||
export = {
|
||||
@@ -43,7 +43,8 @@ export = {
|
||||
]
|
||||
})
|
||||
|
||||
await staffapp.findOneAndDelete({ userID: applicantId })
|
||||
const app = await staffapp.findOne({ where: { userID: applicantId } })
|
||||
await app?.destroy()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -3,9 +3,8 @@ import { embedColor, staffApplicationsChannel } from "config/options"
|
||||
import { largeM, ignM } from "config/limitmessages"
|
||||
import questions from "config/questions"
|
||||
import { guildRole, guildStaff } from "config/roles"
|
||||
import mongoose from "mongoose"
|
||||
import staffapp from "schemas/staffAppSchema"
|
||||
import settings from "schemas/settingsSchema"
|
||||
import staffapp from "schemas/staffAppTag"
|
||||
import settings from "schemas/settingsTag"
|
||||
import { IButton } from "interfaces"
|
||||
import env from "utils/Env"
|
||||
import applicationQuestions from "utils/functions/applicationquestions"
|
||||
@@ -18,8 +17,8 @@ export = {
|
||||
const user = interaction.member as GuildMember
|
||||
const guild = interaction.guild!
|
||||
const userRoles = user.roles.cache
|
||||
const setting = await settings.findOne({ name: "staffAppStatus" })
|
||||
const status = setting!.value || "0"
|
||||
const setting = await settings.findOne({ where: { name: "staffAppStatus" } })
|
||||
const status = setting?.value || "0"
|
||||
const staffQuestions = questions.staff
|
||||
|
||||
function sq(n: number): string {
|
||||
@@ -50,7 +49,7 @@ export = {
|
||||
return
|
||||
}
|
||||
|
||||
const application = await staffapp.findOne({ userID: user.user.id })
|
||||
const application = await staffapp.findOne({ where: { userID: user.user.id } })
|
||||
|
||||
if (application) {
|
||||
await interaction.editReply("You already have an application in progress.")
|
||||
@@ -222,13 +221,11 @@ export = {
|
||||
}]
|
||||
})
|
||||
|
||||
const newStaffApp = new staffapp({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
await staffapp.create({
|
||||
userID: user.user.id,
|
||||
uuid: uuid
|
||||
})
|
||||
|
||||
await newStaffApp.save()
|
||||
await user.deleteDM()
|
||||
|
||||
const channel = guild.channels.cache.get(staffApplicationsChannel) as TextChannel
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import waitinglist from "schemas/waitinglistSchema"
|
||||
import waitinglist from "schemas/waitinglistTag"
|
||||
import { getGuild, getIGN } from "utils/Hypixel"
|
||||
import { hypixelGuildID } from "config/options"
|
||||
import { IButton } from "interfaces"
|
||||
@@ -13,14 +13,14 @@ export = {
|
||||
const user = interaction.user
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const accepted = await waitinglist.find()
|
||||
const accepted = await waitinglist.findAll()
|
||||
|
||||
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 })
|
||||
await accepted[i].destroy()
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user