Skip to content

Commit

Permalink
replaced all table imports by Node subpath imports
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed May 1, 2024
1 parent 2079075 commit f33e0b4
Show file tree
Hide file tree
Showing 26 changed files with 40 additions and 34 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
"git": ">=2.x.x"
},
"imports": {
"#app": "./dist/app.js"
"#app": "./dist/app.js",
"#app/*": "./dist/*",
"#tables/*": "./dist/tables/*"
}
}
2 changes: 1 addition & 1 deletion src/app/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export const orm = new ORM({
logger,
})

export * from "@ghom/orm"
export * from "@ghom/orm"
2 changes: 1 addition & 1 deletion src/commands/autoRole.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as app from "#app"
import autoRole from "../tables/autoRole.js"
import autoRole from "#tables/autoRole.js"

export default new app.Command({
name: "autoRole",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/backup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import restart from "../tables/restart.js"
import restart from "#tables/restart.js"

export default new app.Command({
name: "backup",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import guilds, { Guild } from "../tables/guild.js"
import guilds, { Guild } from "#tables/guild.js"

export default new app.Command({
name: "config",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execSync } from "child_process"

import * as app from "#app"

import restart from "../tables/restart.js"
import restart from "#tables/restart.js"

type State = "waiting" | "running" | "done"
type Command = { cmd: string; state: State; time: number }
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import messages, { Message } from "../tables/message.js"
import messages, { Message } from "#tables/message.js"

export default new app.Command({
name: "fetch",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/labs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as app from "#app"

import lab from "../tables/lab.js"
import guild from "../tables/guild.js"
import lab from "#tables/lab.js"
import guild from "#tables/guild.js"

export default new app.Command({
name: "labs",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/point.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import points from "../tables/point.js"
import points from "#tables/point.js"

export default new app.Command({
name: "point",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/prefix.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import * as app from "#app"

import guilds from "../tables/guild.js"
import guilds from "#tables/guild.js"

export default new app.Command({
name: "prefix",
guildOwnerOnly: true,
channelType: "guild",
description: "Edit or show the bot prefix",
positional: [
app.positional({
{
name: "prefix",
description: "The new prefix",
type: "string",
validate: (value) => value.length < 10 && /^\S/.test(value),
}),
},
],
async run(message) {
const prefix = message.args.prefix
Expand Down
2 changes: 1 addition & 1 deletion src/commands/rating.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import rating from "../tables/rating.js"
import rating from "#tables/rating.js"

export default new app.Command({
name: "rating",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/restart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import restart from "../tables/restart.js"
import restart from "#tables/restart.js"

export default new app.Command({
name: "restart",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/todo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as app from "#app"

import todoTable, { ToDo } from "../tables/todo.js"
import { User } from "../tables/user.js"
import todoTable, { ToDo } from "#tables/todo.js"
import { User } from "#tables/user.js"

import { filename } from "dirname-filename-esm"

Expand Down
2 changes: 1 addition & 1 deletion src/listeners/activity.messageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import messages from "../tables/message.js"
import messages from "#tables/message.js"

const listener: app.Listener<"messageCreate"> = {
event: "messageCreate",
Expand Down
2 changes: 1 addition & 1 deletion src/listeners/clean.guildDelete.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import guilds from "../tables/guild.js"
import guilds from "#tables/guild.js"

const listener: app.Listener<"guildDelete"> = {
event: "guildDelete",
Expand Down
2 changes: 1 addition & 1 deletion src/listeners/clean.guildMemberRemove.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import users from "../tables/user.js"
import users from "#tables/user.js"

const listener: app.Listener<"guildMemberRemove"> = {
event: "guildMemberRemove",
Expand Down
2 changes: 1 addition & 1 deletion src/listeners/points.interactionCreate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import points from "../tables/point.js"
import points from "#tables/point.js"

const listener: app.Listener<"interactionCreate"> = {
event: "interactionCreate",
Expand Down
2 changes: 1 addition & 1 deletion src/listeners/restart.ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as time from "tims"

import * as app from "#app"

import restart, { Restart } from "../tables/restart.js"
import restart, { Restart } from "#tables/restart.js"

import { filename } from "dirname-filename-esm"

Expand Down
8 changes: 4 additions & 4 deletions src/namespaces/active.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as app from "#app"

import { Guild } from "../tables/guild.js"
import messages from "../tables/message.js"
import active from "../tables/active.js"
import message from "../tables/message.js"
import { Guild } from "#tables/guild.js"
import messages from "#tables/message.js"
import active from "#tables/active.js"
import message from "#tables/message.js"

/**
* @param guild_id internal guild id
Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/labs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import lab from "../tables/lab.js"
import lab from "#tables/lab.js"

export const allLabsCache = new app.ResponseCache(
async () => lab.query.select(),
Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as command from "../app/command.js"
import * as logger from "../app/logger.js"
import * as tools from "../namespaces/tools.js"

import { Guild } from "../tables/guild.js"
import { Guild } from "#tables/guild.js"

export function staffOnly(): command.Middleware<"guild"> {
return async function staffOnly(message, data) {
Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/point.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import point from "../tables/point.js"
import point from "#tables/point.js"

export interface PointLadderLine {
target: string
Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/rating.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import table from "../tables/rating.js"
import table from "#tables/rating.js"

export interface RatingLadderLine {
target: string
Expand Down
8 changes: 5 additions & 3 deletions src/namespaces/tools.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as app from "#app"

import users, { User } from "../tables/user.js"
import guilds, { Guild } from "../tables/guild.js"
import autoRole from "../tables/autoRole.js"
import users, { User } from "#tables/user.js"
import guilds, { Guild } from "#tables/guild.js"
import autoRole from "#tables/autoRole.js"

export enum Emotes {
Loading = "865282736041361468",
Expand Down Expand Up @@ -212,6 +212,7 @@ export async function countOf(builder: any, column = "*"): Promise<number> {

export async function prefix(guild?: app.Guild | null): Promise<string> {
let prefix = process.env.BOT_PREFIX as string

if (guild) {
const guildData = await guilds.query
.where("id", guild.id)
Expand All @@ -221,6 +222,7 @@ export async function prefix(guild?: app.Guild | null): Promise<string> {
return guildData.prefix ?? prefix
}
}

return prefix
}

Expand Down
2 changes: 1 addition & 1 deletion src/namespaces/tracker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as app from "#app"

import message from "../tables/message.js"
import message from "#tables/message.js"

export async function updateGuildMemberCountTracker(guild: app.Guild) {
if (process.env.BOT_MODE === "dev") return
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"forceConsistentCasingInFileNames": true,
"paths": {
"#app": ["./src/app.ts"],
"#app/*": ["./src/*"],
"#tables/*": ["./src/tables/*"],
}
},
}

0 comments on commit f33e0b4

Please sign in to comment.