Moved from mongodb to sql and sqlite
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
FROM node:20.9.0-alpine3.18
|
||||
|
||||
RUN apk add git fish openssh gnupg fish
|
||||
RUN yarn global add typescript ts-node nodemon
|
||||
|
||||
RUN sed -i 's/bin\/ash/usr\/bin\/fish/g' /etc/passwd
|
||||
|
||||
FROM node:20.9.0-alpine3.18
|
||||
|
||||
RUN apk add git fish openssh gnupg fish
|
||||
RUN yarn global add typescript ts-node nodemon
|
||||
|
||||
RUN sed -i 's/bin\/ash/usr\/bin\/fish/g' /etc/passwd
|
||||
|
||||
RUN mkdir -p /root/.ssh
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@
|
||||
.yarn/
|
||||
node_modules/*
|
||||
.env
|
||||
dist/
|
||||
dist/
|
||||
data/
|
||||
|
||||
@@ -9,6 +9,8 @@ services:
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: journald
|
||||
volumes:
|
||||
- ${DB_PATH}:/app/data
|
||||
environment:
|
||||
- TOKEN=${TOKEN}
|
||||
- MONGOURI=${MONGOURI}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"ignore": [
|
||||
".git",
|
||||
"node_modules/**/node_modules",
|
||||
"src"
|
||||
"src",
|
||||
"data"
|
||||
],
|
||||
"verbose": true,
|
||||
"env": {
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"restartable": "rs",
|
||||
"ignore": [
|
||||
".git",
|
||||
"node_modules/**/node_modules"
|
||||
"node_modules/**/node_modules",
|
||||
"data"
|
||||
],
|
||||
"verbose": true,
|
||||
"env": {
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
"mongoose": "^8.2.1",
|
||||
"ms": "^2.1.3",
|
||||
"pretty-ms": "^9.0.0",
|
||||
"sequelize": "^6.37.2",
|
||||
"sqlite3": "^5.1.7",
|
||||
"youtube-ext": "^1.1.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -16,10 +16,11 @@ export = {
|
||||
const message = await interaction.channel!.messages.fetch(targetId)
|
||||
|
||||
if (!message) {
|
||||
return interaction.reply({
|
||||
interaction.reply({
|
||||
content: "That user does not exist.",
|
||||
ephemeral: true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const target = message.author
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ApplicationCommandType, ContextMenuCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
|
||||
import { embedColor, devMessage, hypixelGuildID } from "config/options"
|
||||
import { IContextMenu } from "interfaces"
|
||||
import verifySchema from "schemas/verifySchema"
|
||||
import verify from "schemas/verifyTag"
|
||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel"
|
||||
import roleManage from "utils/functions/rolesmanage"
|
||||
import { waitingListRole } from "config/roles"
|
||||
@@ -23,7 +23,7 @@ export = {
|
||||
const targetId = interaction.targetId
|
||||
const user = await interaction.guild!.members.fetch(targetId)
|
||||
const usermentioned = userMention(user.user.id)
|
||||
const verifyData = await verifySchema.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,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: [{
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Message, GuildMember } from "discord.js"
|
||||
import { embedColor } from "config/options"
|
||||
import guildapp from "schemas/guildAppSchema"
|
||||
import guildapp from "schemas/guildAppTag"
|
||||
import { IModal } from "interfaces"
|
||||
|
||||
export = {
|
||||
@@ -78,7 +78,8 @@ export = {
|
||||
responseEmbeds = [responseEmbed]
|
||||
}
|
||||
|
||||
await guildapp.findOneAndDelete({ userID: applicantId })
|
||||
const app = await guildapp.findOne({ where: { userID: applicantId } })
|
||||
await app?.destroy()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: responseEmbeds
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"
|
||||
import { embedColor } from "config/options"
|
||||
import staffapp from "schemas/staffAppSchema"
|
||||
import staffapp from "schemas/staffAppTag"
|
||||
import { IModal } from "interfaces"
|
||||
|
||||
export = {
|
||||
@@ -42,7 +42,8 @@ export = {
|
||||
|
||||
await applicant.send({ embeds: [dmMessage] })
|
||||
|
||||
await staffapp.findOneAndDelete({ userID: applicantId })
|
||||
const app = await staffapp.findOne({ where: { userID: applicantId } })
|
||||
await app?.destroy()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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 { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "config/roles"
|
||||
import { IModal } from "interfaces"
|
||||
import { GuildMember } from "discord.js"
|
||||
@@ -15,7 +14,7 @@ export = {
|
||||
|
||||
const user = interaction.member as GuildMember
|
||||
const ign = interaction.fields.fields.get("verifyign")!.value
|
||||
const verifyData = await verify.findOne({ userID: user.user.id })
|
||||
const verifyData = await verify.findOne({ where: { userID: user.user.id } })
|
||||
if (verifyData) {
|
||||
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
||||
return
|
||||
@@ -124,14 +123,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,9 +0,0 @@
|
||||
import { Schema, model } from "mongoose"
|
||||
|
||||
const guildAppSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true }
|
||||
})
|
||||
|
||||
export = model("guildapp", guildAppSchema, "guildapp")
|
||||
20
src/schemas/guildAppTag.ts
Normal file
20
src/schemas/guildAppTag.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Sequelize, { InferAttributes, InferCreationAttributes, Model } from "sequelize"
|
||||
import { sequelize } from "utils/Illegitimate"
|
||||
|
||||
interface GuildApp extends Model<InferAttributes<GuildApp>, InferCreationAttributes<GuildApp>> {
|
||||
userID: string
|
||||
uuid: string
|
||||
}
|
||||
|
||||
const tag = sequelize.define<GuildApp>("guildApp", {
|
||||
userID: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
uuid: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
})
|
||||
|
||||
export default tag
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Schema, model } from "mongoose"
|
||||
|
||||
const settingsSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
name: { type: String, required: true },
|
||||
value: { type: String, required: true }
|
||||
})
|
||||
|
||||
export = model("settings", settingsSchema, "settings")
|
||||
20
src/schemas/settingsTag.ts
Normal file
20
src/schemas/settingsTag.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Sequelize, { InferAttributes, InferCreationAttributes, Model } from "sequelize"
|
||||
import { sequelize } from "utils/Illegitimate"
|
||||
|
||||
interface Settings extends Model<InferAttributes<Settings>, InferCreationAttributes<Settings>> {
|
||||
name: string
|
||||
value: string
|
||||
}
|
||||
|
||||
const tag = sequelize.define<Settings>("settings", {
|
||||
name: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
value: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
})
|
||||
|
||||
export default tag
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Schema, model } from "mongoose"
|
||||
|
||||
const staffAppSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true }
|
||||
})
|
||||
|
||||
export = model("staffapp", staffAppSchema, "staffapp")
|
||||
20
src/schemas/staffAppTag.ts
Normal file
20
src/schemas/staffAppTag.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Sequelize, { InferAttributes, InferCreationAttributes, Model } from "sequelize"
|
||||
import { sequelize } from "utils/Illegitimate"
|
||||
|
||||
interface StaffApp extends Model<InferAttributes<StaffApp>, InferCreationAttributes<StaffApp>> {
|
||||
userID: string
|
||||
uuid: string
|
||||
}
|
||||
|
||||
const tag = sequelize.define<StaffApp>("staffApp", {
|
||||
userID: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
uuid: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
})
|
||||
|
||||
export default tag
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Schema, model } from "mongoose"
|
||||
|
||||
const verifySchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true }
|
||||
})
|
||||
|
||||
export = model("verify", verifySchema, "verify")
|
||||
20
src/schemas/verifyTag.ts
Normal file
20
src/schemas/verifyTag.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Sequelize, { InferAttributes, InferCreationAttributes, Model } from "sequelize"
|
||||
import { sequelize } from "utils/Illegitimate"
|
||||
|
||||
interface Verify extends Model<InferAttributes<Verify>, InferCreationAttributes<Verify>> {
|
||||
userID: string
|
||||
uuid: string
|
||||
}
|
||||
|
||||
const tag = sequelize.define<Verify>("verify", {
|
||||
userID: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
uuid: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
})
|
||||
|
||||
export default tag
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Schema, model } from "mongoose"
|
||||
|
||||
const waitinglistSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true },
|
||||
timestamp: { type: Number, required: true }
|
||||
})
|
||||
|
||||
export = model("waitinglist", waitinglistSchema, "waitinglist")
|
||||
25
src/schemas/waitinglistTag.ts
Normal file
25
src/schemas/waitinglistTag.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Sequelize, { InferAttributes, InferCreationAttributes, Model } from "sequelize"
|
||||
import { sequelize } from "utils/Illegitimate"
|
||||
|
||||
interface WaitingList extends Model<InferAttributes<WaitingList>, InferCreationAttributes<WaitingList>> {
|
||||
userID: string;
|
||||
uuid: string;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
const tag = sequelize.define<WaitingList>("waitingList", {
|
||||
userID: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
uuid: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
timestamp: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false
|
||||
}
|
||||
})
|
||||
|
||||
export default tag
|
||||
@@ -5,10 +5,17 @@ import env from "utils/Env"
|
||||
import { connect } from "mongoose"
|
||||
import loadAllEvents from "./Events"
|
||||
import { Player } from "discord-player"
|
||||
import { Sequelize } from "sequelize"
|
||||
|
||||
const client = new Client()
|
||||
const redis = new Redis(env.prod.redisURI!)
|
||||
const player = new Player(client)
|
||||
const sequelize = new Sequelize("illegitimate", "root", "password", {
|
||||
host: "localhost",
|
||||
dialect: "sqlite",
|
||||
logging: false,
|
||||
storage: "data/database.sqlite",
|
||||
})
|
||||
|
||||
let ft: "js" | "ts"
|
||||
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") {
|
||||
@@ -33,6 +40,9 @@ class Illegitimate {
|
||||
connect(env.prod.mongoURI!, {}).then(() => {
|
||||
console.log(color("Connected to MongoDB", "green"))
|
||||
})
|
||||
sequelize.sync().then(() => {
|
||||
console.log(color("Connected to SQLite", "green"))
|
||||
})
|
||||
}
|
||||
|
||||
private async init() {
|
||||
@@ -54,4 +64,4 @@ class Illegitimate {
|
||||
}
|
||||
}
|
||||
|
||||
export { Illegitimate, client, redis }
|
||||
export { Illegitimate, client, redis, sequelize }
|
||||
|
||||
Reference in New Issue
Block a user