🏷️ tsconfig-paths (absolute) instead of relative

This commit is contained in:
Axel Olausson Holtenäs 2022-04-13 18:23:28 +02:00
parent 12b970b23e
commit b44d093919
No known key found for this signature in database
GPG key ID: 9347A5E873995701
8 changed files with 195 additions and 174 deletions

6
.gitignore vendored
View file

@ -4,6 +4,12 @@ node_modules
config.json
package-lock.json
**/config/*.ts
!**/config/index.ts
!**/config/example.*.ts
# Logs
logs
*.log

View file

@ -39,12 +39,14 @@
"discord.js": "^13.6.0",
"dotenv": "^16.0.0",
"i18next": "^21.6.13",
"module-alias": "^2.2.2",
"mongoose": "^6.2.3",
"node-schedule": "^2.1.0",
"pino": "^7.0.0-rc.9",
"pino-pretty": "^7.6.1",
"quick.db": "^7.1.3",
"ts-node": "^10.7.0",
"tsconfig-paths": "^3.14.1",
"typescript": "^4.6.3",
"uuid": "^8.3.2",
"winston-daily-rotate-file": "^4.6.1"

View file

@ -0,0 +1,2 @@
export const url =
"mongodb+srv://username:password@server/database?retryWrites=true&w=majority";

View file

@ -1,11 +1,11 @@
import mongoose from "mongoose";
import { url } from "@config/database";
import { mongodb } from "../../config.json";
import logger from "../logger";
import mongoose from "mongoose";
import logger from "@logger";
export default async () => {
await mongoose
.connect(mongodb?.url)
.connect(url)
?.then(async () => {
logger.info("Successfully connected to MongoDB!");
})

View file

@ -1,10 +1,11 @@
// Dependencies
import { Client, Intents } from "discord.js"; // discord.js
import "tsconfig-paths/register";
// Configurations
import { bot } from "../config.json";
import database from "./database";
import database from "@root/database";
import schedules from "./schedules";
// Handlers

View file

@ -7,22 +7,22 @@ export default {
data: (command: SlashCommandSubcommandBuilder) => {
return command
.setName("view")
.setDescription("View a counter.")
.setDescription("View a counter's count.")
.addChannelOption((option) =>
option
.setName("channel")
.setDescription("The counter channel you want to view")
.setDescription("The counter channel you want to view.")
.setRequired(true)
.addChannelType(ChannelType.GuildText as number)
);
},
execute: async (interaction: CommandInteraction, tools: any) => {
const { options, guild } = interaction;
const { colors, footer } = tools.config;
const { config, schemas } = tools;
const discordChannel = options?.getChannel("channel");
const counter = await tools.schemas.counter?.findOne({
const counter = await schemas?.counter?.findOne({
guildId: guild?.id,
channelId: discordChannel?.id,
});
@ -34,8 +34,11 @@ export default {
.setTitle("[:1234:] Counters (View)")
.setDescription(`${discordChannel} is not a counting channel!`)
.setTimestamp(new Date())
.setColor(colors?.error as ColorResolvable)
.setFooter({ text: footer?.text, iconURL: footer?.icon }),
.setColor(config?.colors?.error as ColorResolvable)
.setFooter({
text: config?.footer?.text,
iconURL: config?.footer?.icon,
}),
],
});
}
@ -48,8 +51,11 @@ export default {
`${discordChannel} is currently at number ${counter?.counter}.`
)
.setTimestamp(new Date())
.setColor(colors?.success as ColorResolvable)
.setFooter({ text: footer?.text, iconURL: footer?.icon }),
.setColor(config?.colors?.success as ColorResolvable)
.setFooter({
text: config?.footer?.text,
iconURL: config?.footer?.icon,
}),
],
});
},

View file

@ -1,4 +1,4 @@
import helpers from "../helpers";
import helpers from "@root/helpers";
import config from "../../config.json";
import schemas from "../database/schemas";

View file

@ -14,11 +14,15 @@
"isolatedModules": true,
// "removeComments": true,
"outDir": "./build",
"baseUrl": "./src",
"typeRoots": ["/types/common", "./node_modules/@types"],
"paths": {
"@interface/*": ["./src/Interfaces/*"]
},
"typeRoots": ["./src/types/common", "./node_modules/@types"]
"@interface/*": ["Interfaces/*"],
"@root/*": ["*"],
"@config/*": ["config/*"],
"@logger": ["logger"]
}
},
"exclude": ["./node_modules", "./test"],
"include": ["./src"]
"include": ["./src"],
"exclude": ["./node_modules", "./test"]
}