Updated dir structure

This commit is contained in:
2024-01-15 11:00:11 +01:00
parent 06ab42e258
commit 301ab66f58
26 changed files with 62 additions and 80 deletions

View File

@@ -2,7 +2,7 @@ import { GuildMember, SlashCommandBuilder } from "discord.js"
import snipeCacheSchema from "schemas/snipeCacheSchema"
import { Command } from "interfaces"
import { color } from "config/options.json"
import { SnipeCache } from "utils/Types"
import { SnipeCache } from "typings"
export = {
name: "snipe",

View File

@@ -2,7 +2,7 @@ import { ChannelType, Message } from "discord.js"
import { Event } from "interfaces"
import snipeCacheSchema from "schemas/snipeCacheSchema"
import mongoose from "mongoose"
import { SnipeCache } from "utils/Types"
import { SnipeCache } from "typings"
export = {
name: "snipecache",

View File

@@ -1,4 +1,4 @@
export type SnipeCache = {
type SnipeCache = {
author: string
content: string
channel: string
@@ -6,3 +6,5 @@ export type SnipeCache = {
deletedAt: number
attachments: string[]
}
export default SnipeCache

3
src/typings/index.ts Normal file
View File

@@ -0,0 +1,3 @@
import SnipeCache from "./Types"
export { SnipeCache }

View File

@@ -1,10 +1,6 @@
import { Client, Collection, GatewayIntentBits, Partials } from "discord.js"
import color from "./functions/colors"
import { Command } from "interfaces"
import { ContextMenu } from "interfaces"
import { Button } from "interfaces"
import { Modal } from "interfaces"
import { Autocomplete } from "interfaces"
import { Command, ContextMenu, Button, Modal, Autocomplete } from "interfaces"
import env from "./Env"
import autoDeployCommands from "./Autodeploy"
import { loadAllEvents } from "./Events"

View File

@@ -1,17 +0,0 @@
import { ExtendedClient as Client } from "./Client"
import { loadButtonEvents } from "./eventHandlers"
import { loadSlashCommandsEvents } from "./eventHandlers"
import { loadContextMenuEvents } from "./eventHandlers"
import { loadModalEvents } from "./eventHandlers"
import { loadEvents } from "./eventHandlers"
import { loadAutocompleteEvents } from "./eventHandlers"
type FileType = "js" | "ts"
export function loadAllEvents(client: Client, ft: FileType) {
loadEvents(client)
loadButtonEvents(client, ft)
loadSlashCommandsEvents(client, ft)
loadContextMenuEvents(client, ft)
loadModalEvents(client, ft)
loadAutocompleteEvents(client, ft)
}

19
src/utils/Events/index.ts Normal file
View File

@@ -0,0 +1,19 @@
import { ExtendedClient as Client } from "../Client"
import loadAutocompleteEvents from "./autocomplete"
import loadButtonEvents from "./button"
import loadSlashCommandsEvents from "./command"
import loadContextMenuEvents from "./contextmenu"
import loadCronEvents from "./cron"
import loadEvents from "./events"
import loadModalEvents from "./modal"
type FileType = "js" | "ts"
export function loadAllEvents(client: Client, ft: FileType) {
loadEvents(client)
loadButtonEvents(client, ft)
loadSlashCommandsEvents(client, ft)
loadContextMenuEvents(client, ft)
loadModalEvents(client, ft)
loadAutocompleteEvents(client, ft)
loadCronEvents()
}

View File

@@ -1,12 +0,0 @@
export { skywarsLevel } from "./functions/skywars"
export { bedwarsLevel } from "./functions/bedwars"
export { hypixelLevel } from "./functions/hypixel"
export { formatUuid } from "./functions/uuid"
export { guildLevel, scaledGEXP } from "./functions/guild"
export {
getUUID,
getIGN,
getPlayer,
getGuild,
getHeadURL,
} from "./functions/account"

View File

@@ -0,0 +1,12 @@
export { skywarsLevel } from "./skywars"
export { bedwarsLevel } from "./bedwars"
export { hypixelLevel } from "./hypixel"
export { formatUuid } from "./uuid"
export { guildLevel, scaledGEXP } from "./guild"
export {
getUUID,
getIGN,
getPlayer,
getGuild,
getHeadURL,
} from "./account"

View File

@@ -3,16 +3,13 @@ import color from "utils/functions/colors"
import { Redis } from "ioredis"
import env from "utils/Env"
import { connect } from "mongoose"
import init from "utils/Init"
import { loadCronEvents } from "utils/eventHandlers"
const client = new Client()
const redis = new Redis(env.prod.redisURI!)
class Bot {
async start() {
init()
this.init()
client.start()
loadCronEvents()
redis.on("ready", () => {
console.log(color("Connected to Redis", "green"))
})
@@ -20,6 +17,24 @@ class Bot {
console.log(color("Connected to MongoDB", "green"))
})
}
private async init() {
const prodValues = env.prod
const devValues = env.dev
if (process.env.NODE_ENV === "dev") {
for (const [key, value] of Object.entries(devValues)) {
if (!value) throw new Error(`No ${key} specified`)
}
for (const [key, value] of Object.entries(prodValues)) {
if (!value) throw new Error(`No ${key} specified`)
}
} else {
for (const [key, value] of Object.entries(prodValues)) {
if (!value) throw new Error(`No ${key} specified`)
}
}
}
}
export default { Bot, client, redis }

View File

@@ -1,20 +0,0 @@
import env from "utils/Env"
const prodValues = env.prod
const devValues = env.dev
export default function init() {
if (process.env.NODE_ENV === "dev") {
for (const [key, value] of Object.entries(devValues)) {
if (!value) throw new Error(`No ${key} specified`)
}
for (const [key, value] of Object.entries(prodValues)) {
if (!value) throw new Error(`No ${key} specified`)
}
} else {
for (const [key, value] of Object.entries(prodValues)) {
if (!value) throw new Error(`No ${key} specified`)
}
}
}

View File

@@ -1,17 +0,0 @@
import loadAutocompleteEvents from "./autocomplete"
import loadButtonEvents from "./button"
import loadSlashCommandsEvents from "./command"
import loadContextMenuEvents from "./contextmenu"
import loadCronEvents from "./cron"
import loadEvents from "./events"
import loadModalEvents from "./modal"
export {
loadAutocompleteEvents,
loadButtonEvents,
loadSlashCommandsEvents,
loadContextMenuEvents,
loadCronEvents,
loadEvents,
loadModalEvents,
}

View File

@@ -15,9 +15,10 @@
"baseUrl": ".",
"paths": {
"utils/*": ["src/utils/*"],
"interfaces": ["src/interfaces/index"],
"schemas/*": ["src/schemas/*"],
"config/*": ["src/config/*"],
"interfaces": ["src/interfaces/index"],
"typings": ["src/typings/index"],
}
},
"include": ["src"],