diff --git a/.gitignore b/.gitignore index 3a26c16..0ae1541 100644 --- a/.gitignore +++ b/.gitignore @@ -1,136 +1,142 @@ -json.sqlite -node_modules -.env -config.json -package-lock.json - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* +json.sqlite +node_modules +.env +config.json +package-lock.json + + +**/config/*.ts +!**/config/index.ts +!**/config/example.*.ts + + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/package.json b/package.json index dc1c0e4..ca1435c 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/config/example.database.ts b/src/config/example.database.ts new file mode 100644 index 0000000..501a7ee --- /dev/null +++ b/src/config/example.database.ts @@ -0,0 +1,2 @@ +export const url = + "mongodb+srv://username:password@server/database?retryWrites=true&w=majority"; diff --git a/src/database/index.ts b/src/database/index.ts index d41d5f0..8130eb2 100644 --- a/src/database/index.ts +++ b/src/database/index.ts @@ -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!"); }) diff --git a/src/index.ts b/src/index.ts index 61a5279..21f6dee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 diff --git a/src/plugins/counters/modules/view/index.ts b/src/plugins/counters/modules/view/index.ts index bac20ae..c8476a2 100644 --- a/src/plugins/counters/modules/view/index.ts +++ b/src/plugins/counters/modules/view/index.ts @@ -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, + }), ], }); }, diff --git a/src/tools/index.ts b/src/tools/index.ts index 3b50cb6..5d97e15 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,4 +1,4 @@ -import helpers from "../helpers"; +import helpers from "@root/helpers"; import config from "../../config.json"; import schemas from "../database/schemas"; diff --git a/tsconfig.json b/tsconfig.json index 565e6a7..49af458 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,24 +1,28 @@ -{ - "compilerOptions": { - "target": "es2019", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "module": "commonjs", - "resolveJsonModule": true, - "isolatedModules": true, - // "removeComments": true, - "outDir": "./build", - "paths": { - "@interface/*": ["./src/Interfaces/*"] - }, - "typeRoots": ["./src/types/common", "./node_modules/@types"] - }, - "exclude": ["./node_modules", "./test"], - "include": ["./src"] -} +{ + "compilerOptions": { + "target": "es2019", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "module": "commonjs", + "resolveJsonModule": true, + "isolatedModules": true, + // "removeComments": true, + "outDir": "./build", + "baseUrl": "./src", + "typeRoots": ["/types/common", "./node_modules/@types"], + "paths": { + "@interface/*": ["Interfaces/*"], + "@root/*": ["*"], + "@config/*": ["config/*"], + "@logger": ["logger"] + } + }, + "include": ["./src"], + "exclude": ["./node_modules", "./test"] +}