diff --git a/src/commands/snipe.ts b/src/commands/snipe.ts index 1cc6455..77d55a7 100644 --- a/src/commands/snipe.ts +++ b/src/commands/snipe.ts @@ -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", diff --git a/src/events/server/messages/snipecache.ts b/src/events/server/messages/snipecache.ts index 9b0f147..45fd579 100644 --- a/src/events/server/messages/snipecache.ts +++ b/src/events/server/messages/snipecache.ts @@ -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", diff --git a/src/utils/Types.ts b/src/typings/Types.ts similarity index 72% rename from src/utils/Types.ts rename to src/typings/Types.ts index 2cbf5e8..9378e77 100644 --- a/src/utils/Types.ts +++ b/src/typings/Types.ts @@ -1,8 +1,10 @@ -export type SnipeCache = { +type SnipeCache = { author: string content: string channel: string createdAt: number deletedAt: number attachments: string[] -} \ No newline at end of file +} + +export default SnipeCache \ No newline at end of file diff --git a/src/typings/index.ts b/src/typings/index.ts new file mode 100644 index 0000000..adfe505 --- /dev/null +++ b/src/typings/index.ts @@ -0,0 +1,3 @@ +import SnipeCache from "./Types" + +export { SnipeCache } \ No newline at end of file diff --git a/src/utils/Client.ts b/src/utils/Client.ts index 461697c..86fbb1f 100644 --- a/src/utils/Client.ts +++ b/src/utils/Client.ts @@ -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" diff --git a/src/utils/Events.ts b/src/utils/Events.ts deleted file mode 100644 index d32e6bd..0000000 --- a/src/utils/Events.ts +++ /dev/null @@ -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) -} diff --git a/src/utils/eventHandlers/autocomplete.ts b/src/utils/Events/autocomplete.ts similarity index 100% rename from src/utils/eventHandlers/autocomplete.ts rename to src/utils/Events/autocomplete.ts diff --git a/src/utils/eventHandlers/button.ts b/src/utils/Events/button.ts similarity index 100% rename from src/utils/eventHandlers/button.ts rename to src/utils/Events/button.ts diff --git a/src/utils/eventHandlers/command.ts b/src/utils/Events/command.ts similarity index 100% rename from src/utils/eventHandlers/command.ts rename to src/utils/Events/command.ts diff --git a/src/utils/eventHandlers/contextmenu.ts b/src/utils/Events/contextmenu.ts similarity index 100% rename from src/utils/eventHandlers/contextmenu.ts rename to src/utils/Events/contextmenu.ts diff --git a/src/utils/eventHandlers/cron.ts b/src/utils/Events/cron.ts similarity index 100% rename from src/utils/eventHandlers/cron.ts rename to src/utils/Events/cron.ts diff --git a/src/utils/eventHandlers/events.ts b/src/utils/Events/events.ts similarity index 100% rename from src/utils/eventHandlers/events.ts rename to src/utils/Events/events.ts diff --git a/src/utils/Events/index.ts b/src/utils/Events/index.ts new file mode 100644 index 0000000..86d6f1f --- /dev/null +++ b/src/utils/Events/index.ts @@ -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() +} diff --git a/src/utils/eventHandlers/modal.ts b/src/utils/Events/modal.ts similarity index 100% rename from src/utils/eventHandlers/modal.ts rename to src/utils/Events/modal.ts diff --git a/src/utils/Hypixel.ts b/src/utils/Hypixel.ts deleted file mode 100644 index 275907d..0000000 --- a/src/utils/Hypixel.ts +++ /dev/null @@ -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" diff --git a/src/utils/functions/account.ts b/src/utils/Hypixel/account.ts similarity index 100% rename from src/utils/functions/account.ts rename to src/utils/Hypixel/account.ts diff --git a/src/utils/functions/bedwars.ts b/src/utils/Hypixel/bedwars.ts similarity index 100% rename from src/utils/functions/bedwars.ts rename to src/utils/Hypixel/bedwars.ts diff --git a/src/utils/functions/guild.ts b/src/utils/Hypixel/guild.ts similarity index 100% rename from src/utils/functions/guild.ts rename to src/utils/Hypixel/guild.ts diff --git a/src/utils/functions/hypixel.ts b/src/utils/Hypixel/hypixel.ts similarity index 100% rename from src/utils/functions/hypixel.ts rename to src/utils/Hypixel/hypixel.ts diff --git a/src/utils/Hypixel/index.ts b/src/utils/Hypixel/index.ts new file mode 100644 index 0000000..3ad47bf --- /dev/null +++ b/src/utils/Hypixel/index.ts @@ -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" diff --git a/src/utils/functions/skywars.ts b/src/utils/Hypixel/skywars.ts similarity index 100% rename from src/utils/functions/skywars.ts rename to src/utils/Hypixel/skywars.ts diff --git a/src/utils/functions/uuid.ts b/src/utils/Hypixel/uuid.ts similarity index 100% rename from src/utils/functions/uuid.ts rename to src/utils/Hypixel/uuid.ts diff --git a/src/utils/Illegitimate.ts b/src/utils/Illegitimate.ts index f346416..bc625c5 100644 --- a/src/utils/Illegitimate.ts +++ b/src/utils/Illegitimate.ts @@ -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 } diff --git a/src/utils/Init.ts b/src/utils/Init.ts deleted file mode 100644 index 04b741f..0000000 --- a/src/utils/Init.ts +++ /dev/null @@ -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`) - } - } -} diff --git a/src/utils/eventHandlers/index.ts b/src/utils/eventHandlers/index.ts deleted file mode 100644 index 4d26817..0000000 --- a/src/utils/eventHandlers/index.ts +++ /dev/null @@ -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, -} diff --git a/tsconfig.json b/tsconfig.json index 855b0ae..c6ac425 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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"],