Moved from mongodb to sql and sqlite
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
|
||||
import { embedColor } from "config/options"
|
||||
import mongoose from "mongoose"
|
||||
import { ICommand } from "interfaces"
|
||||
import settings from "schemas/settingsSchema"
|
||||
import settings from "schemas/settingsTag"
|
||||
|
||||
export = {
|
||||
name: "config",
|
||||
description: "Configure the bot",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: false,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -37,17 +36,14 @@ export = {
|
||||
|
||||
const setting = interaction.options.getString("setting")!
|
||||
const value = interaction.options.getString("value")!
|
||||
const settingsData = await settings.findOne({ name: setting })
|
||||
const settingsData = await settings.findOne({ where: { name: setting } })
|
||||
|
||||
if (!settingsData) {
|
||||
const newSetting = new settings({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
await settings.create({
|
||||
name: setting,
|
||||
value: value
|
||||
})
|
||||
|
||||
await newSetting.save()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Successfully created `" + setting + "` with value `" + value + "`.",
|
||||
@@ -55,7 +51,7 @@ export = {
|
||||
}]
|
||||
})
|
||||
} else {
|
||||
await settings.findOneAndUpdate({ name: setting }, { value: value })
|
||||
await settingsData.destroy()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { devMessage, embedColor } from "config/options"
|
||||
import { PermissionFlagsBits, SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { ICommand } from "interfaces"
|
||||
import verifySchema from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { getHeadURL, getIGN, getUUID } from "utils/Hypixel"
|
||||
|
||||
export = {
|
||||
name: "find",
|
||||
description: "Find a person by the ign",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: false,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -37,7 +37,7 @@ export = {
|
||||
return
|
||||
}
|
||||
|
||||
const verifyData = await verifySchema.findOne({ uuid: uuid })
|
||||
const verifyData = await verify.findOne({ where: { uuid: uuid } })
|
||||
if (!verifyData) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
|
||||
import { embedColor, devMessage } from "config/options"
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { ICommand } from "interfaces"
|
||||
import roleManage from "utils/functions/rolesmanage"
|
||||
import logToChannel from "utils/functions/logtochannel"
|
||||
@@ -10,7 +10,7 @@ import { removeIndents } from "utils/functions/funcs"
|
||||
export = {
|
||||
name: "forceunverify",
|
||||
description: "Force unverify a user",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: false,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -27,21 +27,22 @@ export = {
|
||||
|
||||
async execute({ interaction }) {
|
||||
const member = interaction.options.getMember("user") as GuildMember
|
||||
const verifiedUser = await verify.findOne({ userID: member.user.id })
|
||||
const verifiedUser = await verify.findOne({ where: { userID: member.user.id } })
|
||||
const mod = interaction.user
|
||||
|
||||
if (!verifiedUser) {
|
||||
return interaction.reply({
|
||||
interaction.reply({
|
||||
embeds: [{
|
||||
description: "This user is not verified",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const uuid = verifiedUser.uuid
|
||||
const ign = await getIGN(uuid)
|
||||
await verify.findOneAndDelete({ userID: member.user.id })
|
||||
await verifiedUser.destroy()
|
||||
await member.roles.remove(
|
||||
roleManage("all").rolesToRemove,
|
||||
"User force unverified by " + interaction.user.username
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
|
||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel"
|
||||
import { hypixelGuildID, embedColor, devMessage } from "config/options"
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { ICommand } from "interfaces"
|
||||
import roleManage from "utils/functions/rolesmanage"
|
||||
import { waitingListRole } from "config/roles"
|
||||
@@ -10,7 +10,7 @@ import { removeIndents } from "utils/functions/funcs"
|
||||
export = {
|
||||
name: "forceupdate",
|
||||
description: "Force update the user",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: false,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -30,7 +30,7 @@ export = {
|
||||
|
||||
const user = interaction.options.getMember("user") as GuildMember
|
||||
const usermentioned = userMention(user.user.id)
|
||||
const verifyData = await verify.findOne({ userID: user.user.id })
|
||||
const verifyData = await verify.findOne({ where: { userID: user.user.id } })
|
||||
|
||||
if (!verifyData) {
|
||||
await user.setNickname(`${user.user.username} (X)`, "User used the update command").catch(() => {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits, GuildMember, userMention } from "discord.js"
|
||||
import { getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
|
||||
import { embedColor, hypixelGuildID, devMessage } from "config/options"
|
||||
import verify from "schemas/verifySchema"
|
||||
import mongoose from "mongoose"
|
||||
import verify from "schemas/verifyTag"
|
||||
import roleManage from "utils/functions/rolesmanage"
|
||||
import { ICommand } from "interfaces"
|
||||
import logToChannel from "utils/functions/logtochannel"
|
||||
@@ -11,7 +10,7 @@ import { removeIndents } from "utils/functions/funcs"
|
||||
export = {
|
||||
name: "forceverify",
|
||||
description: "Force verify a user.",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: false,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -37,7 +36,7 @@ export = {
|
||||
const ign = interaction.options.getString("ign")
|
||||
const mod = interaction.user
|
||||
|
||||
const verifyData = await verify.findOne({ userID: user.user.id })
|
||||
const verifyData = await verify.findOne({ where: { userID: user.user.id } })
|
||||
if (verifyData) {
|
||||
interaction.editReply("That user is already verified.")
|
||||
return
|
||||
@@ -160,14 +159,11 @@ export = {
|
||||
// Do nothing
|
||||
})
|
||||
|
||||
const newVerify = new verify({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: user.id,
|
||||
uuid: uuid
|
||||
await verify.create({
|
||||
userID: user.user.id,
|
||||
uuid: uuid,
|
||||
})
|
||||
|
||||
await newVerify.save()
|
||||
|
||||
await logToChannel("mod", {
|
||||
embeds: [{
|
||||
author: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
|
||||
import { embedColor, devMessage } from "config/options"
|
||||
import waitinglistSchema from "schemas/waitinglistSchema"
|
||||
import waitinglist from "schemas/waitinglistTag"
|
||||
import { ICommand } from "interfaces"
|
||||
import logToChannel from "utils/functions/logtochannel"
|
||||
import { waitingListRole } from "config/roles"
|
||||
@@ -9,7 +9,7 @@ import { removeIndents } from "utils/functions/funcs"
|
||||
export = {
|
||||
name: "remove",
|
||||
description: "Remove a person on the waiting list.",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: false,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -36,7 +36,7 @@ export = {
|
||||
const member = interaction.options.getMember("user") as GuildMember
|
||||
const reason = interaction.options.getString("reason") ?? "No reason provided."
|
||||
const mod = interaction.user!
|
||||
const waitinglist = await waitinglistSchema.findOne({ userID: member.user.id })
|
||||
const waiting = await waitinglist.findOne({ where: { userID: member.user.id } })
|
||||
|
||||
if (!waitinglist) {
|
||||
await interaction.editReply({
|
||||
@@ -48,7 +48,7 @@ export = {
|
||||
return
|
||||
}
|
||||
|
||||
await waitinglistSchema.findOneAndDelete({ userID: member.user.id })
|
||||
await waiting?.destroy()
|
||||
await member.roles.remove(waitingListRole, "Removed from waiting list.")
|
||||
|
||||
await logToChannel("mod", {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { embedColor, hypixelGuildID } from "config/options"
|
||||
import { ChatInputCommandInteraction, GuildMember } from "discord.js"
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { IGuildData } from "interfaces"
|
||||
import env from "utils/Env"
|
||||
import { getGuild } from "utils/Hypixel"
|
||||
@@ -34,17 +34,7 @@ export default async function removeGuildRoles(interaction: ChatInputCommandInte
|
||||
|
||||
const hypixelGuildMembers = guildData.members.map(gmember => gmember.uuid)
|
||||
|
||||
const allVerifiedUsers = (await verify.find({})) as {
|
||||
userID: string
|
||||
uuid: string
|
||||
}[]
|
||||
|
||||
const verifiedUsers = allVerifiedUsers.map(user => {
|
||||
return {
|
||||
userID: user.userID,
|
||||
uuid: user.uuid
|
||||
}
|
||||
})
|
||||
const verifiedUsers = await verify.findAll({})
|
||||
|
||||
for (const gmember of guildMembers) {
|
||||
const gmemberuuid = verifiedUsers.find(user => user.userID === gmember.id)?.uuid
|
||||
@@ -60,4 +50,4 @@ export default async function removeGuildRoles(interaction: ChatInputCommandInte
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { embedColor, hypixelGuildID } from "config/options"
|
||||
import color from "utils/functions/colors"
|
||||
import { verifyTick } from "config/roles"
|
||||
@@ -42,16 +42,7 @@ export default async function updateAll(interaction: ChatInputCommandInteraction
|
||||
})
|
||||
const guildMemberIDs = hypixelGuildMembers.map(gmember => gmember.uuid)
|
||||
|
||||
const allVerifiedUsers = (await verify.find({})) as {
|
||||
userID: string
|
||||
uuid: string
|
||||
}[]
|
||||
const verifiedUsers = allVerifiedUsers.map(user => {
|
||||
return {
|
||||
userID: user.userID,
|
||||
uuid: user.uuid
|
||||
}
|
||||
})
|
||||
const verifiedUsers = await verify.findAll({})
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { GuildMember, SlashCommandBuilder } from "discord.js"
|
||||
import { getGuild, getIGN, getHeadURL } from "utils/Hypixel"
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { embedColor, hypixelGuildID, devMessage } from "config/options"
|
||||
import roleManage from "utils/functions/rolesmanage"
|
||||
import { ICommand } from "interfaces"
|
||||
@@ -10,7 +10,7 @@ import { removeIndents } from "utils/functions/funcs"
|
||||
export = {
|
||||
name: "update",
|
||||
description: "Update your guild rank.",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: true,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -22,7 +22,7 @@ export = {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.member as GuildMember
|
||||
const verifyData = await verify.findOne({ userID: user.user.id })
|
||||
const verifyData = await verify.findOne({ where: { userID: user.user.id } })
|
||||
|
||||
if (!verifyData) {
|
||||
await user.setNickname(`${user.user.username} (X)`, "User used the update command").catch(() => {
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { GuildMember, SlashCommandBuilder } from "discord.js"
|
||||
import { getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
|
||||
import { embedColor, hypixelGuildID, devMessage } from "config/options"
|
||||
import mongoose from "mongoose"
|
||||
import roleManage from "utils/functions/rolesmanage"
|
||||
import { ICommand } from "interfaces"
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { IPlayerData } from "interfaces"
|
||||
import { IGuildData } from "interfaces"
|
||||
|
||||
export = {
|
||||
name: "verify",
|
||||
description: "Verify yourself as a member of the server.",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: true,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -33,7 +32,7 @@ export = {
|
||||
const user = interaction.member! as GuildMember
|
||||
const ign = interaction.options.getString("ign")!
|
||||
|
||||
const verifyData = await verify.findOne({ userID: user.id })
|
||||
const verifyData = await verify.findOne({ where: { userID: user.id } })
|
||||
if (verifyData) {
|
||||
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
||||
return
|
||||
@@ -178,14 +177,11 @@ export = {
|
||||
// Do nothing
|
||||
})
|
||||
|
||||
const newVerify = new verify({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
await verify.create({
|
||||
userID: user.id,
|
||||
uuid: uuid
|
||||
})
|
||||
|
||||
await newVerify.save()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: interaction.guild!.name,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { SlashCommandBuilder, userMention } from "discord.js"
|
||||
import { ICommand } from "interfaces"
|
||||
import { embedColor, devMessage } from "config/options"
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { getIGN, getHeadURL } from "utils/Hypixel"
|
||||
|
||||
export = {
|
||||
name: "whoami",
|
||||
description: "Get your user info",
|
||||
public: true,
|
||||
dev: false,
|
||||
dev: true,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("whoami")
|
||||
@@ -19,7 +19,7 @@ export = {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.user
|
||||
const verifyData = await verify.findOne({ userID: user.id })
|
||||
const verifyData = await verify.findOne({ where: { userID: user.id } })
|
||||
|
||||
if (!verifyData) {
|
||||
await interaction.editReply({
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
|
||||
import { getIGN, getHeadURL } from "utils/Hypixel"
|
||||
import { embedColor, devMessage } from "config/options"
|
||||
import verify from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { ICommand } from "interfaces"
|
||||
|
||||
export = {
|
||||
name: "whois",
|
||||
description: "Get's the ign of a user.",
|
||||
dev: false,
|
||||
dev: true,
|
||||
public: false,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -26,7 +26,7 @@ export = {
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.options.getUser("user")!
|
||||
const verifiedUser = await verify.findOne({ userID: user.id })
|
||||
const verifiedUser = await verify.findOne({ where: { userID: user.id } })
|
||||
if (!verifiedUser) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
Reference in New Issue
Block a user