diff --git a/src/app.ts b/src/app.ts index cfae3387..3a499096 100644 --- a/src/app.ts +++ b/src/app.ts @@ -29,8 +29,7 @@ import deleteThreadMessagesHandler from "./handler/deleteThreadMessagesHandler.j import * as terminal from "./terminal.js"; import * as guildRageQuit from "./storage/guildRageQuit.js"; import { scheduleCronjobs } from "./handler/cronjobs.js"; - -const args = process.argv.slice(2); +import { args } from "./utils/configHandler.js"; { const prodMode = @@ -146,7 +145,7 @@ client.once("ready", async initializedClient => { void fadingMessageHandler.startLoop(client); log.info("Bot successfully started"); - if (args.includes("--dry-run")) { + if (args.values["dry-run"]) { process.exit(0); } } catch (err) { diff --git a/src/utils/configHandler.ts b/src/utils/configHandler.ts index 7ff8b612..7e5cde16 100644 --- a/src/utils/configHandler.ts +++ b/src/utils/configHandler.ts @@ -1,5 +1,6 @@ import * as fs from "node:fs"; import * as path from "node:path"; +import { parseArgs } from "node:util"; import log from "@log"; import type { Config } from "../types.js"; @@ -37,3 +38,12 @@ export const databasePath = export const rapidApiInstagramApiKey = process.env.RAPID_API_INSTAGRAM_API_KEY || undefined; + +export const args = parseArgs({ + options: { + "dry-run": { + type: "boolean", + description: "Run the bot in dry-run mode", + }, + }, +});