@abdarrahmanabdelnasir/relay-node 0.1.11 → 0.1.12
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 +11 -3
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ function getEnv(name, optional = false) {
|
|
|
14
14
|
|
|
15
15
|
const token = getEnv('BOT_TOKEN');
|
|
16
16
|
const apiKey = getEnv('COMMANDLESS_API_KEY');
|
|
17
|
+
const botId = getEnv('BOT_ID');
|
|
17
18
|
const baseUrl = process.env.COMMANDLESS_SERVICE_URL; // Optional - defaults to Commandless backend
|
|
18
19
|
const hmacSecret = process.env.COMMANDLESS_HMAC_SECRET;
|
|
19
20
|
|
|
@@ -34,10 +35,17 @@ useDiscordAdapter({ client, relay, mentionRequired: true });
|
|
|
34
35
|
client.once('ready', async () => {
|
|
35
36
|
console.log(`[commandless] Logged in as ${client.user.tag}`);
|
|
36
37
|
try {
|
|
37
|
-
const
|
|
38
|
-
|
|
38
|
+
const registeredBotId = await relay.registerBot({
|
|
39
|
+
platform: 'discord',
|
|
40
|
+
name: client.user.username,
|
|
41
|
+
clientId: client.user.id,
|
|
42
|
+
botId: parseInt(botId, 10)
|
|
43
|
+
});
|
|
44
|
+
if (registeredBotId) relay.botId = registeredBotId;
|
|
45
|
+
console.log(`[commandless] Bot registered with ID: ${registeredBotId}`);
|
|
39
46
|
} catch (e) {
|
|
40
|
-
console.
|
|
47
|
+
console.error('[commandless] registerBot failed:', e?.message || e);
|
|
48
|
+
process.exit(1);
|
|
41
49
|
}
|
|
42
50
|
setInterval(async () => { try { await relay.heartbeat(); } catch {} }, 30_000);
|
|
43
51
|
});
|