Moved from sequlize to drizzleorm
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { embedColor } from "config/options.js"
|
||||
import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"
|
||||
import { ICommand } from "interfaces"
|
||||
import settings from "schemas/settingsTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { settings } from "src/db/schema.js"
|
||||
|
||||
export default {
|
||||
name: "config",
|
||||
@@ -36,10 +37,12 @@ export default {
|
||||
|
||||
const setting = interaction.options.getString("setting")!
|
||||
const value = interaction.options.getString("value")!
|
||||
const settingsData = await settings.findOne({ where: { name: setting } })
|
||||
const settingsData = await db.query.settings.findFirst({
|
||||
where: (settings, { eq }) => eq(settings.name, setting)
|
||||
})
|
||||
|
||||
if (!settingsData) {
|
||||
await settings.create({
|
||||
await db.insert(settings).values({
|
||||
name: setting,
|
||||
value: value
|
||||
})
|
||||
@@ -51,7 +54,9 @@ export default {
|
||||
}]
|
||||
})
|
||||
} else {
|
||||
await settingsData.destroy()
|
||||
await db.update(settings).set({
|
||||
value: value
|
||||
})
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { devMessage, embedColor } from "config/options.js"
|
||||
import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import { getHeadURL, getIGN, getUUID } from "utils/Hypixel.js"
|
||||
|
||||
export default {
|
||||
@@ -37,7 +39,9 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
const verifyData = await verify.findOne({ where: { uuid: uuid } })
|
||||
const verifyData = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.uuid, uuid)
|
||||
})
|
||||
if (!verifyData) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { devMessage, embedColor } from "config/options.js"
|
||||
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import logToChannel from "utils/functions/logtochannel.js"
|
||||
import roleManage from "utils/functions/rolesmanage.js"
|
||||
import { getIGN } from "utils/Hypixel.js"
|
||||
@@ -26,7 +28,9 @@ export default {
|
||||
|
||||
async execute({ interaction }) {
|
||||
const member = interaction.options.getMember("user") as GuildMember
|
||||
const verifiedUser = await verify.findOne({ where: { userID: member.user.id } })
|
||||
const verifiedUser = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.userID, member.user.id)
|
||||
})
|
||||
const mod = interaction.user
|
||||
|
||||
if (!verifiedUser) {
|
||||
@@ -41,7 +45,7 @@ export default {
|
||||
|
||||
const uuid = verifiedUser.uuid
|
||||
const ign = await getIGN(uuid)
|
||||
await verifiedUser.destroy()
|
||||
await db.delete(verifies).where(eq(verifies.userID, member.user.id))
|
||||
await member.roles.remove(
|
||||
roleManage("all").rolesToRemove,
|
||||
"User force unverified by " + interaction.user.username
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||
import { waitingListRole } from "config/roles.js"
|
||||
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import roleManage from "utils/functions/rolesmanage.js"
|
||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||
|
||||
@@ -29,7 +31,9 @@ export default {
|
||||
|
||||
const user = interaction.options.getMember("user") as GuildMember
|
||||
const usermentioned = userMention(user.user.id)
|
||||
const verifyData = await verify.findOne({ where: { userID: user.user.id } })
|
||||
const verifyData = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.userID, user.user.id)
|
||||
})
|
||||
|
||||
if (!verifyData) {
|
||||
await user.setNickname(`${user.user.username} (X)`, "User used the update command").catch(() => {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import logToChannel from "utils/functions/logtochannel.js"
|
||||
import roleManage from "utils/functions/rolesmanage.js"
|
||||
import { getGuild, getHeadURL, getPlayer, getUUID } from "utils/Hypixel.js"
|
||||
@@ -35,7 +37,9 @@ export default {
|
||||
const ign = interaction.options.getString("ign")
|
||||
const mod = interaction.user
|
||||
|
||||
const verifyData = await verify.findOne({ where: { userID: user.user.id } })
|
||||
const verifyData = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.userID, user.user.id)
|
||||
})
|
||||
if (verifyData) {
|
||||
interaction.editReply("That user is already verified.")
|
||||
return
|
||||
@@ -160,7 +164,7 @@ export default {
|
||||
// Do nothing
|
||||
})
|
||||
|
||||
await verify.create({
|
||||
await db.insert(verifies).values({
|
||||
userID: user.user.id,
|
||||
uuid: uuid
|
||||
})
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { devMessage, embedColor } from "config/options.js"
|
||||
import { waitingListRole } from "config/roles.js"
|
||||
import { GuildMember, InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import waitinglist from "schemas/waitinglistTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { waitingLists } from "src/db/schema.js"
|
||||
import logToChannel from "utils/functions/logtochannel.js"
|
||||
|
||||
export default {
|
||||
@@ -35,9 +37,11 @@ export default {
|
||||
const member = interaction.options.getMember("user") as GuildMember
|
||||
const reason = interaction.options.getString("reason") ?? "No reason provided."
|
||||
const mod = interaction.user!
|
||||
const waiting = await waitinglist.findOne({ where: { userID: member.user.id } })
|
||||
const waiting = await db.query.waitingLists.findFirst({
|
||||
where: eq(waitingLists.userID, member.user.id)
|
||||
})
|
||||
|
||||
if (!waitinglist) {
|
||||
if (!waiting) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: userMention(member.user.id) + " is not on the waiting list.",
|
||||
@@ -47,7 +51,7 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
await waiting?.destroy()
|
||||
await db.delete(waitingLists).where(eq(waitingLists.userID, member.user.id))
|
||||
await member.roles.remove(waitingListRole, "Removed from waiting list.")
|
||||
|
||||
await logToChannel("mod", {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { embedColor, hypixelGuildID } from "config/options.js"
|
||||
import { ChatInputCommandInteraction, GuildMember } from "discord.js"
|
||||
import { IGuildData } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import env from "utils/Env.js"
|
||||
import roleManage from "utils/functions/rolesmanage.js"
|
||||
import { getGuild } from "utils/Hypixel.js"
|
||||
@@ -35,7 +35,7 @@ export default async function removeGuildRoles(interaction: ChatInputCommandInte
|
||||
|
||||
const hypixelGuildMembers = guildData.members.map(gmember => gmember.uuid)
|
||||
|
||||
const verifiedUsers = await verify.findAll({})
|
||||
const verifiedUsers = await db.query.verifies.findMany({})
|
||||
|
||||
for (const gmember of guildMembers) {
|
||||
const gmemberuuid = verifiedUsers.find(user => user.userID === gmember.id)?.uuid
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { embedColor, hypixelGuildID } from "config/options.js"
|
||||
import { ChannelType, ChatInputCommandInteraction, GuildMember } from "discord.js"
|
||||
import { IGuildData } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import env from "utils/Env.js"
|
||||
import { color } from "utils/functions/colors.js"
|
||||
import roleManage from "utils/functions/rolesmanage.js"
|
||||
@@ -53,7 +53,7 @@ export default async function updateAll(interaction: ChatInputCommandInteraction
|
||||
})
|
||||
const guildMemberIDs = hypixelGuildMembers.map(gmember => gmember.uuid)
|
||||
|
||||
const verifiedUsers = await verify.findAll({})
|
||||
const verifiedUsers = await db.query.verifies.findMany()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||
import { waitingListRole } from "config/roles.js"
|
||||
import { GuildMember, InteractionContextType, SlashCommandBuilder } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import roleManage from "utils/functions/rolesmanage.js"
|
||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||
|
||||
@@ -21,7 +23,9 @@ export default {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.member as GuildMember
|
||||
const verifyData = await verify.findOne({ where: { userID: user.user.id } })
|
||||
const verifyData = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.userID, user.user.id)
|
||||
})
|
||||
|
||||
if (!verifyData) {
|
||||
await user.setNickname(`${user.user.username} (X)`, "User used the update command").catch(() => {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { devMessage, embedColor, hypixelGuildID } from "config/options.js"
|
||||
import { GuildMember, InteractionContextType, SlashCommandBuilder } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import { IPlayerData } from "interfaces"
|
||||
import { IGuildData } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import roleManage from "utils/functions/rolesmanage.js"
|
||||
import { getGuild, getHeadURL, getPlayer, getUUID } from "utils/Hypixel.js"
|
||||
|
||||
@@ -32,7 +34,9 @@ export default {
|
||||
const user = interaction.member! as GuildMember
|
||||
const ign = interaction.options.getString("ign")!
|
||||
|
||||
const verifyData = await verify.findOne({ where: { userID: user.id } })
|
||||
const verifyData = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.userID, user.user.id)
|
||||
})
|
||||
if (verifyData) {
|
||||
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
||||
return
|
||||
@@ -178,7 +182,7 @@ export default {
|
||||
// Do nothing
|
||||
})
|
||||
|
||||
await verify.create({
|
||||
await db.insert(verifies).values({
|
||||
userID: user.id,
|
||||
uuid: uuid
|
||||
})
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { devMessage, embedColor } from "config/options.js"
|
||||
import { InteractionContextType, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import { getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||
|
||||
export default {
|
||||
@@ -19,7 +21,9 @@ export default {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.user
|
||||
const verifyData = await verify.findOne({ where: { userID: user.id } })
|
||||
const verifyData = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.userID, user.id)
|
||||
})
|
||||
|
||||
if (!verifyData) {
|
||||
await interaction.editReply({
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { devMessage, embedColor } from "config/options.js"
|
||||
import { InteractionContextType, PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifyTag.js"
|
||||
import db from "src/db/db.js"
|
||||
import { verifies } from "src/db/schema.js"
|
||||
import { getHeadURL, getIGN } from "utils/Hypixel.js"
|
||||
|
||||
export default {
|
||||
@@ -26,7 +28,9 @@ export default {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.options.getUser("user")!
|
||||
const verifiedUser = await verify.findOne({ where: { userID: user.id } })
|
||||
const verifiedUser = await db.query.verifies.findFirst({
|
||||
where: eq(verifies.userID, user.id)
|
||||
})
|
||||
if (!verifiedUser) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
Reference in New Issue
Block a user