@abdarrahmanabdelnasir/relay-node 0.1.19 → 0.1.20

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.
@@ -35,6 +35,12 @@ const client = new Client({
35
35
 
36
36
  const relay = new RelayClient({ apiKey, baseUrl, hmacSecret });
37
37
 
38
+ // Set botId from env immediately (for config enforcement)
39
+ if (botId) {
40
+ relay.botId = parseInt(botId, 10);
41
+ console.log(`[commandless] Bot ID set from env: ${relay.botId}`);
42
+ }
43
+
38
44
  useDiscordAdapter({ client, relay, mentionRequired: true });
39
45
 
40
46
  client.once('ready', async () => {
@@ -46,11 +52,17 @@ client.once('ready', async () => {
46
52
  clientId: client.user.id,
47
53
  botId: parseInt(botId, 10)
48
54
  });
49
- if (registeredBotId) relay.botId = registeredBotId;
50
- console.log(`[commandless] Bot registered with ID: ${registeredBotId}`);
55
+ // Update botId if registration succeeded and returned a different ID
56
+ if (registeredBotId) {
57
+ relay.botId = registeredBotId;
58
+ console.log(`[commandless] Bot registered with ID: ${registeredBotId}`);
59
+ } else {
60
+ console.log(`[commandless] Registration returned null, using env BOT_ID: ${relay.botId}`);
61
+ }
51
62
  } catch (e) {
52
63
  console.error('[commandless] registerBot failed:', e?.message || e);
53
- process.exit(1);
64
+ // Don't exit - botId is already set from env, so config enforcement will still work
65
+ console.log(`[commandless] Continuing with botId from env: ${relay.botId}`);
54
66
  }
55
67
  setInterval(async () => { try { await relay.heartbeat(); } catch {} }, 30_000);
56
68
  });
@@ -70,6 +70,7 @@ export function useDiscordAdapter(opts) {
70
70
  content: message.content,
71
71
  timestamp: message.createdTimestamp,
72
72
  botClientId: client.user?.id,
73
+ botId: relay.botId || undefined, // Include botId for backend config enforcement
73
74
  isReplyToBot,
74
75
  referencedMessageId: message.reference?.messageId,
75
76
  referencedMessageAuthorId: message.reference ? client.user?.id : undefined,
@@ -121,6 +122,7 @@ export function useDiscordAdapter(opts) {
121
122
  return out;
122
123
  })(),
123
124
  timestamp: Date.now(),
125
+ botId: relay.botId || undefined, // Include botId for backend config enforcement
124
126
  };
125
127
  try {
126
128
  const dec = await relay.sendEvent(evt);
package/dist/types.d.ts CHANGED
@@ -8,6 +8,7 @@ export type RelayEvent = {
8
8
  content: string;
9
9
  timestamp: number;
10
10
  botClientId?: Snowflake;
11
+ botId?: number | string;
11
12
  isReplyToBot?: boolean;
12
13
  referencedMessageId?: string;
13
14
  referencedMessageAuthorId?: Snowflake;
@@ -22,6 +23,7 @@ export type RelayEvent = {
22
23
  options?: Record<string, unknown>;
23
24
  timestamp: number;
24
25
  botClientId?: Snowflake;
26
+ botId?: number | string;
25
27
  };
26
28
  export interface Decision {
27
29
  id: string;
@@ -73,6 +73,7 @@ function useDiscordAdapter(opts) {
73
73
  content: message.content,
74
74
  timestamp: message.createdTimestamp,
75
75
  botClientId: client.user?.id,
76
+ botId: relay.botId || undefined, // Include botId for backend config enforcement
76
77
  isReplyToBot,
77
78
  referencedMessageId: message.reference?.messageId,
78
79
  referencedMessageAuthorId: message.reference ? client.user?.id : undefined,
@@ -124,6 +125,7 @@ function useDiscordAdapter(opts) {
124
125
  return out;
125
126
  })(),
126
127
  timestamp: Date.now(),
128
+ botId: relay.botId || undefined, // Include botId for backend config enforcement
127
129
  };
128
130
  try {
129
131
  const dec = await relay.sendEvent(evt);
@@ -8,6 +8,7 @@ export type RelayEvent = {
8
8
  content: string;
9
9
  timestamp: number;
10
10
  botClientId?: Snowflake;
11
+ botId?: number | string;
11
12
  isReplyToBot?: boolean;
12
13
  referencedMessageId?: string;
13
14
  referencedMessageAuthorId?: Snowflake;
@@ -22,6 +23,7 @@ export type RelayEvent = {
22
23
  options?: Record<string, unknown>;
23
24
  timestamp: number;
24
25
  botClientId?: Snowflake;
26
+ botId?: number | string;
25
27
  };
26
28
  export interface Decision {
27
29
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abdarrahmanabdelnasir/relay-node",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",