@abdarrahmanabdelnasir/relay-node 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commandless-discord.js +5 -0
- package/dist/http.js +4 -0
- package/dist/relayClient.js +3 -0
- package/dist-cjs/http.js +4 -0
- package/dist-cjs/relayClient.js +3 -0
- package/package.json +1 -1
|
@@ -18,6 +18,11 @@ const botId = getEnv('BOT_ID');
|
|
|
18
18
|
const baseUrl = process.env.COMMANDLESS_SERVICE_URL; // Optional - defaults to Commandless backend
|
|
19
19
|
const hmacSecret = process.env.COMMANDLESS_HMAC_SECRET;
|
|
20
20
|
|
|
21
|
+
// Log API key for debugging (first 15 chars only)
|
|
22
|
+
console.log(`[commandless] Using API key: ${apiKey.substring(0, 15)}... (full length: ${apiKey.length})`);
|
|
23
|
+
console.log(`[commandless] Using BOT_ID: ${botId}`);
|
|
24
|
+
console.log(`[commandless] Using base URL: ${baseUrl || 'https://api.commandless.app'}`);
|
|
25
|
+
|
|
21
26
|
const client = new Client({
|
|
22
27
|
intents: [
|
|
23
28
|
GatewayIntentBits.Guilds,
|
package/dist/http.js
CHANGED
|
@@ -15,16 +15,20 @@ export async function postJson(url, apiKey, body, opts) {
|
|
|
15
15
|
if (opts?.idempotencyKey)
|
|
16
16
|
headers["x-idempotency-key"] = opts.idempotencyKey;
|
|
17
17
|
try {
|
|
18
|
+
console.log(`[commandless] postJson: ${url.substring(0, 50)}...`);
|
|
18
19
|
const res = await fetch(url, { method: "POST", body: json, headers, signal: controller.signal });
|
|
19
20
|
const requestId = res.headers.get("x-request-id") ?? undefined;
|
|
20
21
|
if (!res.ok) {
|
|
21
22
|
const text = await safeText(res);
|
|
23
|
+
console.error(`[commandless] postJson failed: ${res.status} ${text.substring(0, 200)}`);
|
|
22
24
|
return { ok: false, status: res.status, error: text, requestId };
|
|
23
25
|
}
|
|
24
26
|
const data = (await res.json());
|
|
25
27
|
return { ok: true, status: res.status, data, requestId };
|
|
26
28
|
}
|
|
27
29
|
catch (err) {
|
|
30
|
+
console.error(`[commandless] postJson fetch error:`, err?.message || err);
|
|
31
|
+
console.error(`[commandless] postJson URL was:`, url);
|
|
28
32
|
return { ok: false, status: 0, error: err?.message ?? String(err) };
|
|
29
33
|
}
|
|
30
34
|
finally {
|
package/dist/relayClient.js
CHANGED
|
@@ -14,6 +14,8 @@ export class RelayClient {
|
|
|
14
14
|
async registerBot(info) {
|
|
15
15
|
try {
|
|
16
16
|
const url = `${this.baseUrl}/v1/relay/register`;
|
|
17
|
+
console.log(`[commandless] registerBot URL: ${url}`);
|
|
18
|
+
console.log(`[commandless] registerBot payload:`, { ...info, botId: info.botId });
|
|
17
19
|
const res = await postJson(url, this.apiKey, info, {
|
|
18
20
|
hmacSecret: this.hmacSecret,
|
|
19
21
|
timeoutMs: this.timeoutMs,
|
|
@@ -33,6 +35,7 @@ export class RelayClient {
|
|
|
33
35
|
}
|
|
34
36
|
catch (err) {
|
|
35
37
|
console.error(`[commandless] registerBot exception:`, err?.message || err);
|
|
38
|
+
console.error(`[commandless] Full error:`, err);
|
|
36
39
|
return null;
|
|
37
40
|
}
|
|
38
41
|
}
|
package/dist-cjs/http.js
CHANGED
|
@@ -18,16 +18,20 @@ async function postJson(url, apiKey, body, opts) {
|
|
|
18
18
|
if (opts?.idempotencyKey)
|
|
19
19
|
headers["x-idempotency-key"] = opts.idempotencyKey;
|
|
20
20
|
try {
|
|
21
|
+
console.log(`[commandless] postJson: ${url.substring(0, 50)}...`);
|
|
21
22
|
const res = await fetch(url, { method: "POST", body: json, headers, signal: controller.signal });
|
|
22
23
|
const requestId = res.headers.get("x-request-id") ?? undefined;
|
|
23
24
|
if (!res.ok) {
|
|
24
25
|
const text = await safeText(res);
|
|
26
|
+
console.error(`[commandless] postJson failed: ${res.status} ${text.substring(0, 200)}`);
|
|
25
27
|
return { ok: false, status: res.status, error: text, requestId };
|
|
26
28
|
}
|
|
27
29
|
const data = (await res.json());
|
|
28
30
|
return { ok: true, status: res.status, data, requestId };
|
|
29
31
|
}
|
|
30
32
|
catch (err) {
|
|
33
|
+
console.error(`[commandless] postJson fetch error:`, err?.message || err);
|
|
34
|
+
console.error(`[commandless] postJson URL was:`, url);
|
|
31
35
|
return { ok: false, status: 0, error: err?.message ?? String(err) };
|
|
32
36
|
}
|
|
33
37
|
finally {
|
package/dist-cjs/relayClient.js
CHANGED
|
@@ -17,6 +17,8 @@ class RelayClient {
|
|
|
17
17
|
async registerBot(info) {
|
|
18
18
|
try {
|
|
19
19
|
const url = `${this.baseUrl}/v1/relay/register`;
|
|
20
|
+
console.log(`[commandless] registerBot URL: ${url}`);
|
|
21
|
+
console.log(`[commandless] registerBot payload:`, { ...info, botId: info.botId });
|
|
20
22
|
const res = await (0, http_js_1.postJson)(url, this.apiKey, info, {
|
|
21
23
|
hmacSecret: this.hmacSecret,
|
|
22
24
|
timeoutMs: this.timeoutMs,
|
|
@@ -36,6 +38,7 @@ class RelayClient {
|
|
|
36
38
|
}
|
|
37
39
|
catch (err) {
|
|
38
40
|
console.error(`[commandless] registerBot exception:`, err?.message || err);
|
|
41
|
+
console.error(`[commandless] Full error:`, err);
|
|
39
42
|
return null;
|
|
40
43
|
}
|
|
41
44
|
}
|