Updated querying
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||||
import { waitingListRole } from "config/roles.js"
|
import { waitingListRole } from "config/roles.js"
|
||||||
import { ApplicationCommandType, ContextMenuCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
|
import { ApplicationCommandType, ContextMenuCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { IContextMenu } from "interfaces"
|
import { IContextMenu } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
|
||||||
import roleManage from "utils/functions/rolesmanage.js"
|
import roleManage from "utils/functions/rolesmanage.js"
|
||||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||||
|
|
||||||
@@ -25,7 +23,7 @@ export default {
|
|||||||
const user = await interaction.guild!.members.fetch(targetId)
|
const user = await interaction.guild!.members.fetch(targetId)
|
||||||
const usermentioned = userMention(user.user.id)
|
const usermentioned = userMention(user.user.id)
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!verifyData) {
|
if (!verifyData) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default {
|
|||||||
const setting = interaction.options.getString("setting")!
|
const setting = interaction.options.getString("setting")!
|
||||||
const value = interaction.options.getString("value")!
|
const value = interaction.options.getString("value")!
|
||||||
const settingsData = await db.query.settings.findFirst({
|
const settingsData = await db.query.settings.findFirst({
|
||||||
where: (settings, { eq }) => eq(settings.name, setting)
|
where: ({ name }, { eq }) => eq(name, setting)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!settingsData) {
|
if (!settingsData) {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { devMessage, embedColor } from "config/options.js"
|
import { devMessage, embedColor } from "config/options.js"
|
||||||
import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { ICommand } from "interfaces"
|
import { ICommand } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
|
||||||
import { getHeadURL, getIGN, getUUID } from "utils/Hypixel.js"
|
import { getHeadURL, getIGN, getUUID } from "utils/Hypixel.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -40,7 +38,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.uuid, uuid)
|
where: ({ uuid: uuidfromdb }, { eq }) => eq(uuidfromdb, uuid)
|
||||||
})
|
})
|
||||||
if (!verifyData) {
|
if (!verifyData) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default {
|
|||||||
async execute({ interaction }) {
|
async execute({ interaction }) {
|
||||||
const member = interaction.options.getMember("user") as GuildMember
|
const member = interaction.options.getMember("user") as GuildMember
|
||||||
const verifiedUser = await db.query.verifies.findFirst({
|
const verifiedUser = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, member.user.id)
|
where: ({ userID }, { eq }) => eq(userID, member.user.id)
|
||||||
})
|
})
|
||||||
const mod = interaction.user
|
const mod = interaction.user
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||||
import { waitingListRole } from "config/roles.js"
|
import { waitingListRole } from "config/roles.js"
|
||||||
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { ICommand } from "interfaces"
|
import { ICommand } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
|
||||||
import roleManage from "utils/functions/rolesmanage.js"
|
import roleManage from "utils/functions/rolesmanage.js"
|
||||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||||
|
|
||||||
@@ -32,7 +30,7 @@ export default {
|
|||||||
const user = interaction.options.getMember("user") as GuildMember
|
const user = interaction.options.getMember("user") as GuildMember
|
||||||
const usermentioned = userMention(user.user.id)
|
const usermentioned = userMention(user.user.id)
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.user.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!verifyData) {
|
if (!verifyData) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||||
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { ICommand } from "interfaces"
|
import { ICommand } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
import { verifies } from "src/db/schema.js"
|
||||||
@@ -38,7 +37,7 @@ export default {
|
|||||||
const mod = interaction.user
|
const mod = interaction.user
|
||||||
|
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.user.id)
|
||||||
})
|
})
|
||||||
if (verifyData) {
|
if (verifyData) {
|
||||||
interaction.editReply("That user is already verified.")
|
interaction.editReply("That user is already verified.")
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default {
|
|||||||
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 waiting = await db.query.waitingLists.findFirst({
|
const waiting = await db.query.waitingLists.findFirst({
|
||||||
where: eq(waitingLists.userID, member.user.id)
|
where: ({ userID }, { eq }) => eq(userID, member.user.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!waiting) {
|
if (!waiting) {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||||
import { waitingListRole } from "config/roles.js"
|
import { waitingListRole } from "config/roles.js"
|
||||||
import { GuildMember, InteractionContextType, SlashCommandBuilder } from "discord.js"
|
import { GuildMember, InteractionContextType, SlashCommandBuilder } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { ICommand } from "interfaces"
|
import { ICommand } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
|
||||||
import roleManage from "utils/functions/rolesmanage.js"
|
import roleManage from "utils/functions/rolesmanage.js"
|
||||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||||
|
|
||||||
@@ -24,7 +22,7 @@ export default {
|
|||||||
|
|
||||||
const user = interaction.member as GuildMember
|
const user = interaction.member as GuildMember
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.user.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!verifyData) {
|
if (!verifyData) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||||
import { GuildMember, InteractionContextType, SlashCommandBuilder } from "discord.js"
|
import { GuildMember, InteractionContextType, SlashCommandBuilder } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { ICommand } from "interfaces"
|
import { ICommand } from "interfaces"
|
||||||
import { IPlayerData } from "interfaces"
|
import { IPlayerData } from "interfaces"
|
||||||
import { IGuildData } from "interfaces"
|
import { IGuildData } from "interfaces"
|
||||||
@@ -35,7 +34,7 @@ export default {
|
|||||||
const ign = interaction.options.getString("ign")!
|
const ign = interaction.options.getString("ign")!
|
||||||
|
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.id)
|
||||||
})
|
})
|
||||||
if (verifyData) {
|
if (verifyData) {
|
||||||
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { devMessage, embedColor } from "config/options.js"
|
import { devMessage, embedColor } from "config/options.js"
|
||||||
import { InteractionContextType, SlashCommandBuilder, userMention } from "discord.js"
|
import { InteractionContextType, SlashCommandBuilder, userMention } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { ICommand } from "interfaces"
|
import { ICommand } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
|
||||||
import { getHeadURL, getIGN } from "utils/Hypixel.js"
|
import { getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -22,7 +20,7 @@ export default {
|
|||||||
|
|
||||||
const user = interaction.user
|
const user = interaction.user
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!verifyData) {
|
if (!verifyData) {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { devMessage, embedColor } from "config/options.js"
|
import { devMessage, embedColor } from "config/options.js"
|
||||||
import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { ICommand } from "interfaces"
|
import { ICommand } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
|
||||||
import { getHeadURL, getIGN } from "utils/Hypixel.js"
|
import { getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -29,7 +27,7 @@ export default {
|
|||||||
|
|
||||||
const user = interaction.options.getUser("user")!
|
const user = interaction.options.getUser("user")!
|
||||||
const verifiedUser = await db.query.verifies.findFirst({
|
const verifiedUser = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.id)
|
||||||
})
|
})
|
||||||
if (!verifiedUser) {
|
if (!verifiedUser) {
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import { devMessage, embedColor } from "config/options.js"
|
import { devMessage, embedColor } from "config/options.js"
|
||||||
import { bwfkdr, bwstars, bwwins, duelswins, duelswlr, swkdr, swstars } from "config/reqs.js"
|
import { bwfkdr, bwstars, bwwins, duelswins, duelswlr, swkdr, swstars } from "config/reqs.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { IButton } from "interfaces"
|
import { IButton } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { guildApps } from "src/db/schema.js"
|
|
||||||
import { bedwarsLevel, getGuild, getHeadURL, getPlayer, hypixelLevel, skywarsLevel } from "utils/Hypixel.js"
|
import { bedwarsLevel, getGuild, getHeadURL, getPlayer, hypixelLevel, skywarsLevel } from "utils/Hypixel.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -17,7 +15,7 @@ export default {
|
|||||||
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 guildappdata = await db.query.guildApps.findFirst({
|
const guildappdata = await db.query.guildApps.findFirst({
|
||||||
where: eq(guildApps.userID, applicantId)
|
where: ({ userID }, { eq }) => eq(userID, applicantId)
|
||||||
})
|
})
|
||||||
const uuid = guildappdata!.uuid
|
const uuid = guildappdata!.uuid
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const applicantEntry = await db.query.guildApps.findFirst({
|
const applicantEntry = await db.query.guildApps.findFirst({
|
||||||
where: eq(guildApps.userID, applicantId)
|
where: ({ userID }, { eq }) => eq(userID, applicantId)
|
||||||
})
|
})
|
||||||
const applicantUUID = applicantEntry!.uuid
|
const applicantUUID = applicantEntry!.uuid
|
||||||
const time = Date.now()
|
const time = Date.now()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { applicationsChannel, embedColor } from "config/options.js"
|
|||||||
import { guild as guildQuestions } from "config/questions.js"
|
import { guild as guildQuestions } from "config/questions.js"
|
||||||
import { guildRole } from "config/roles.js"
|
import { guildRole } from "config/roles.js"
|
||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, GuildMember, TextChannel } from "discord.js"
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, GuildMember, TextChannel } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { IButton } from "interfaces"
|
import { IButton } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { guildApps } from "src/db/schema.js"
|
import { guildApps } from "src/db/schema.js"
|
||||||
@@ -33,7 +32,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const application = await db.query.guildApps.findFirst({
|
const application = await db.query.guildApps.findFirst({
|
||||||
where: eq(guildApps.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.user.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (application) {
|
if (application) {
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ import { embedColor, staffApplicationsChannel } from "config/options.js"
|
|||||||
import { staff as staffQuestions } from "config/questions.js"
|
import { staff as staffQuestions } from "config/questions.js"
|
||||||
import { guildRole, guildStaff } from "config/roles.js"
|
import { guildRole, guildStaff } from "config/roles.js"
|
||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, GuildMember, TextChannel } from "discord.js"
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, GuildMember, TextChannel } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { IButton } from "interfaces"
|
import { IButton } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { settings, staffApps } from "src/db/schema.js"
|
import { staffApps } from "src/db/schema.js"
|
||||||
import env from "utils/Env.js"
|
import env from "utils/Env.js"
|
||||||
import applicationQuestions from "utils/functions/applicationquestions.js"
|
import applicationQuestions from "utils/functions/applicationquestions.js"
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ export default {
|
|||||||
const guild = interaction.guild!
|
const guild = interaction.guild!
|
||||||
const userRoles = user.roles.cache
|
const userRoles = user.roles.cache
|
||||||
const setting = await db.query.settings.findFirst({
|
const setting = await db.query.settings.findFirst({
|
||||||
where: eq(settings.name, "staffApplications")
|
where: ({ name }, { eq }) => eq(name, "staffApplications")
|
||||||
})
|
})
|
||||||
const status = setting?.value || "0"
|
const status = setting?.value || "0"
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const application = await db.query.staffApps.findFirst({
|
const application = await db.query.staffApps.findFirst({
|
||||||
where: eq(staffApps.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.user.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (application) {
|
if (application) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||||
import { GuildMember } from "discord.js"
|
import { GuildMember } from "discord.js"
|
||||||
import { eq } from "drizzle-orm"
|
|
||||||
import { IModal } from "interfaces"
|
import { IModal } from "interfaces"
|
||||||
import db from "src/db/db.js"
|
import db from "src/db/db.js"
|
||||||
import { verifies } from "src/db/schema.js"
|
import { verifies } from "src/db/schema.js"
|
||||||
@@ -17,7 +16,7 @@ export default {
|
|||||||
const user = interaction.member as GuildMember
|
const user = interaction.member as GuildMember
|
||||||
const ign = interaction.fields.fields.get("verifyign")!.value
|
const ign = interaction.fields.fields.get("verifyign")!.value
|
||||||
const verifyData = await db.query.verifies.findFirst({
|
const verifyData = await db.query.verifies.findFirst({
|
||||||
where: eq(verifies.userID, user.user.id)
|
where: ({ userID }, { eq }) => eq(userID, user.id)
|
||||||
})
|
})
|
||||||
if (verifyData) {
|
if (verifyData) {
|
||||||
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
||||||
|
|||||||
Reference in New Issue
Block a user