JonasJ
Deno2y ago
Jonas

Compile to exe

Every time I run my exe I get the following error,
But when I start my code normally with node main.js it works without problems.
This is my Code:
import Discord, { Guild } from "discord.js";
import inquirer from "inquirer";
import { discordChoose, getBotToken } from "../../../lib/discord/main.js";
import { getRole } from "../../../lib/helper.js";

export const bot = async () => {
  const token = await getBotToken();
  const client = new Discord.Client({
    intents: [
      Discord.GatewayIntentBits.Guilds,
      Discord.GatewayIntentBits.GuildMembers,
      Discord.GatewayIntentBits.GuildIntegrations,
      Discord.GatewayIntentBits.GuildVoiceStates,
      Discord.GatewayIntentBits.MessageContent,
      Discord.GatewayIntentBits.GuildMessages,
    ],
  });

  process.on("unhandledRejection", (error: any) => {
    console.log(chalk.red("An error occurred:"));
    if (error.message === "Used disallowed intents") {
      console.log(
        chalk.red(
          "The bot needs the following intents to work:\n- MESSAGE CONTENT INTENT\n- SERVER MEMBERS INTENT"
        )
      );
    } else {
      console.log(chalk.red(error.message));
    }
    discordChoose();
    return;
  });

  client
    .login(token)
    .then(() => {
      choose(client);
    })
    .catch(() => {
      console.log(chalk.red("Invalid token!"));
      discordChoose();
      return;
    });
};


This is my package.json:
{
  "type": "module",
  "scripts": {
    "start": "tsc && node dist/main.js",
    "build": "deno compile dist/main.js"
  },
  "license": "ISC",
  "devDependencies": {
    "@types/figlet": "^1.5.8",
    "@types/gradient-string": "^1.1.5",
    "@types/inquirer": "^9.0.7",
    "@types/node": "^20.10.0",
    "typescript": "^5.3.2"
  },
  "dependencies": {
    "axios": "^1.6.5",
    "chalk": "^5.3.0",
    "discord.js": "^14.14.1",
    "dotenv": "^16.4.1",
    "figlet": "^1.7.0",
    "inquirer": "^9.2.12",
    "nanospinner": "^1.1.0",
  }
}
image.png
Was this page helpful?