From 3289e1fa451a19e20dca020d62ca3cec0a885e0d Mon Sep 17 00:00:00 2001 From: Vliegenier04 Date: Thu, 12 Dec 2024 21:55:50 +0100 Subject: [PATCH] Fix: change to absolute paths (running scripts is usually not allowed on hosters) --- package.json | 5 +++-- src/classes/bot.ts | 10 +++++----- src/commands/blacklist.ts | 12 ++++++------ src/commands/promote-demote.ts | 2 +- src/commands/toggle-mute.ts | 2 +- src/events/discord/interaction-create.ts | 2 +- src/events/discord/message.ts | 4 ++-- src/events/discord/ready.ts | 2 +- src/index.ts | 2 +- src/requests/fetch-hypixel-guild.ts | 2 +- src/requests/fetch-hypixel-player-profile.ts | 2 +- tsconfig.json | 1 + 12 files changed, 24 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 63ed6a35..9f8f9f00 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "pm2:kill": "pm2 kill", "pm2:start": "pm2 start dist/index.js --attach --name bridge", "setup-files": "node scripts/setup-files.js", - "start": "node ." + "start": "node -r tsconfig-paths/register dist/index.js" }, "dependencies": { "consola": "^2.15.3", @@ -25,7 +25,8 @@ "obscenity": "^0.1.4", "pnpm": "^9.14.2", "prismarine-chat": "^1.10.1", - "zod": "^3.23.8" + "zod": "^3.23.8", + "tsconfig-paths": "^4.2.0" }, "devDependencies": { "@jejebecarte/eslint-config": "^1.0.6", diff --git a/src/classes/bot.ts b/src/classes/bot.ts index 1e7d88b6..779fa2db 100644 --- a/src/classes/bot.ts +++ b/src/classes/bot.ts @@ -9,11 +9,11 @@ import { BotEvents, createBot } from 'mineflayer'; import logger from 'consola'; import EventEmitter from 'events'; import path from 'path'; -import isObjKey from '@util/is-obj-key'; -import logError from '@util/log-error'; -import recursiveWalkDir from '@util/recursive-walk-dir'; -import regex from '@events/regex'; -import env from '@util/env'; +import isObjKey from '../util/is-obj-key'; +import logError from '../util/log-error'; +import recursiveWalkDir from '../util/recursive-walk-dir'; +import regex from '../events/regex'; +import env from '../util/env'; import Discord from './client'; class Bot { diff --git a/src/commands/blacklist.ts b/src/commands/blacklist.ts index 6fdf0c85..845e24b2 100644 --- a/src/commands/blacklist.ts +++ b/src/commands/blacklist.ts @@ -1,10 +1,10 @@ import { ApplicationCommandOptionType, EmbedBuilder, TextChannel } from 'discord.js'; -import env from '@util/env'; -import _blacklist from '@blacklist/_blacklist.json'; -import writeToJsonFile from '@util/write-to-json-file'; -import fetchErrorEmbed from '@requests/fetch-error-embed'; -import fetchMojangProfile from '@requests/fetch-mojang-profile'; -import isFetchError from '@requests/is-fetch-error'; +import env from '../util/env'; +import _blacklist from '../blacklist/_blacklist.json'; +import writeToJsonFile from '../util/write-to-json-file'; +import fetchErrorEmbed from '../requests/fetch-error-embed'; +import fetchMojangProfile from '../requests/fetch-mojang-profile'; +import isFetchError from '../requests/is-fetch-error'; export default { data: { diff --git a/src/commands/promote-demote.ts b/src/commands/promote-demote.ts index eba20e91..ba5224d2 100644 --- a/src/commands/promote-demote.ts +++ b/src/commands/promote-demote.ts @@ -1,5 +1,5 @@ import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; -import capitaliseString from '@util/capitalise-string'; +import capitaliseString from '../util/capitalise-string'; export default { data: { diff --git a/src/commands/toggle-mute.ts b/src/commands/toggle-mute.ts index 3663eb35..fd146c4e 100644 --- a/src/commands/toggle-mute.ts +++ b/src/commands/toggle-mute.ts @@ -1,5 +1,5 @@ import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; -import capitaliseString from '@util/capitalise-string'; +import capitaliseString from '../util/capitalise-string'; export default { data: { diff --git a/src/events/discord/interaction-create.ts b/src/events/discord/interaction-create.ts index 639e8bf9..5c90634d 100644 --- a/src/events/discord/interaction-create.ts +++ b/src/events/discord/interaction-create.ts @@ -1,6 +1,6 @@ import logger from 'consola'; import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, Interaction } from 'discord.js'; -import env from '@util/env'; +import env from '../../util/env'; export default { name: 'interactionCreate', diff --git a/src/events/discord/message.ts b/src/events/discord/message.ts index 37b6e2e3..14eed451 100644 --- a/src/events/discord/message.ts +++ b/src/events/discord/message.ts @@ -1,8 +1,8 @@ import logger from 'consola'; import { Message } from 'discord.js'; import { DataSet, RegExpMatcher, englishDataset, englishRecommendedTransformers } from 'obscenity'; -import emojis from '@util/emojis'; -import env from '@util/env'; +import emojis from '../../util/emojis'; +import env from '../../util/env'; const whitelist = ['ass', 'bitch', 'cock', 'dick', 'fuck']; const dataset = new DataSet<{ originalWord: string }>() diff --git a/src/events/discord/ready.ts b/src/events/discord/ready.ts index 3237daf0..c911e217 100644 --- a/src/events/discord/ready.ts +++ b/src/events/discord/ready.ts @@ -1,5 +1,5 @@ import { TextChannel } from 'discord.js'; -import env from '@util/env'; +import env from '../../util/env'; export default { name: 'ready', diff --git a/src/index.ts b/src/index.ts index 270f9ce3..bb48e946 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,3 @@ -import Bot from '@classes/bot'; +import Bot from './classes/bot'; export default new Bot(); diff --git a/src/requests/fetch-hypixel-guild.ts b/src/requests/fetch-hypixel-guild.ts index 1d7c1f8f..d13f653b 100644 --- a/src/requests/fetch-hypixel-guild.ts +++ b/src/requests/fetch-hypixel-guild.ts @@ -1,4 +1,4 @@ -import env from '@util/env'; +import env from '../util/env'; export default async (uuid: string) => { const response = await fetch( diff --git a/src/requests/fetch-hypixel-player-profile.ts b/src/requests/fetch-hypixel-player-profile.ts index 5370c5c5..36df9698 100644 --- a/src/requests/fetch-hypixel-player-profile.ts +++ b/src/requests/fetch-hypixel-player-profile.ts @@ -1,4 +1,4 @@ -import env from '@util/env'; +import env from '../util/env'; export default async (username: string) => { const response = await fetch( diff --git a/tsconfig.json b/tsconfig.json index ad6ddc90..bb847bd4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "allowJs": false, "skipLibCheck": true, "isolatedModules": true, + "baseUrl": "", "paths": { "@blacklist/*": ["./src/blacklist/*"], "@classes/*": ["./src/classes/*"],