Skip to content

Commit

Permalink
fix: better client login logs, fix dynamic pm detection
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Best-Codes committed Jan 6, 2025
1 parent 3092671 commit 67d5fef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discraft",
"version": "1.6.2-beta.7",
"version": "1.6.2-beta.8",
"description": "Ultimate Discord bot framework",
"type": "module",
"packageManager": "bun@1.1.42",
Expand Down
17 changes: 10 additions & 7 deletions package/src/cli/init/detectPm.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { execSync } from "child_process";

function getEnvVar(key: string): string | undefined {
// Create a completely isolated dynamic lookup.
// This is necessary to avoid static replacement of process.env.SOME_VARIABLE
if (Object.prototype.hasOwnProperty.call(process.env, key)) {
return process.env[key];
}
return undefined;
}

async function detectPackageManager(): Promise<string | undefined> {
// Access process.env dynamically to avoid static replacement during build
const userAgent = Object.prototype.hasOwnProperty.call(
process.env,
"npm_config_user_agent",
)
? process.env.npm_config_user_agent
: undefined;
const userAgent = getEnvVar("npm_config_user_agent");

if (userAgent) {
if (userAgent.startsWith("bun")) {
Expand Down
4 changes: 3 additions & 1 deletion templates/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ registerEvents(client)
}
});
client.login(process.env.DISCORD_TOKEN).catch((err) => {
logger.error("Client login failed.");
logger.error(
"Client login failed, make sure your token is set correctly.",
);
logger.verbose(err);
});
});
Expand Down

0 comments on commit 67d5fef

Please sign in to comment.