From a1b2b3fb2c957808b213902292120cc03d1bba1c Mon Sep 17 00:00:00 2001 From: Skillz Date: Mon, 8 May 2023 13:36:33 -0500 Subject: [PATCH] fix: Closes #3011 guide fixes --- website/docs/bigbot/step-2-rest.md | 4 ++-- website/docs/bigbot/step-3-gateway.md | 5 +++-- website/docs/bigbot/step-4-bot.md | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/website/docs/bigbot/step-2-rest.md b/website/docs/bigbot/step-2-rest.md index 61187dcea..44d1fb1dd 100644 --- a/website/docs/bigbot/step-2-rest.md +++ b/website/docs/bigbot/step-2-rest.md @@ -64,8 +64,8 @@ app.all('/*', async (req, res) => { try { const result = await REST.makeRequest( req.method, - `${REST.baseUrl}${req.url}`, - req.body + req.url.substring(4), + { body: req.method !== 'DELETE' && req.method !== 'GET' ? {} : req.body } ) if (result) { diff --git a/website/docs/bigbot/step-3-gateway.md b/website/docs/bigbot/step-3-gateway.md index 24eb53704..687a3af44 100644 --- a/website/docs/bigbot/step-3-gateway.md +++ b/website/docs/bigbot/step-3-gateway.md @@ -58,7 +58,7 @@ export const GATEWAY = createGatewayManager({ connection: await REST.getSessionInfo(), }) -// More code to be added here but first you need to understand this part. +GATEWAY.spawnShards() ``` Now let's break it down. @@ -149,6 +149,7 @@ GATEWAY.tellWorkerToIdentify = async function (workerId, shardId, bucketId) { method: 'POST', headers: { authorization: process.env.AUTHORIZATION, + "Content-type": "application/json", }, body: JSON.stringify({ type: 'IDENTIFY_SHARD', shardId }), }) @@ -156,7 +157,7 @@ GATEWAY.tellWorkerToIdentify = async function (workerId, shardId, bucketId) { .catch(logger.error) } -// More code to be added here but first you need to understand this part. +GATEWAY.spawnShards() ``` Here, we are overriding the built in method on the gateway manager called `tellWorkerToIdentify`. Internally, this function just simply starts a new shard as by default the lib supports small bots. For our case, we are going to make it get the server url from a `.env` file diff --git a/website/docs/bigbot/step-4-bot.md b/website/docs/bigbot/step-4-bot.md index 6ba2c4e4b..9fa7ea36e 100644 --- a/website/docs/bigbot/step-4-bot.md +++ b/website/docs/bigbot/step-4-bot.md @@ -114,7 +114,7 @@ try { // OPTIONAL: Runs the raw event handler if you need it bot.events.raw(bot, req.body.payload, req.body.shardId); // Runs the event handler if available - if (message.t) bot.events.[snakeToCamelCase(message.t)]?.(req.body.payload, req.body.shardId); + if (message.t) bot.events.[snakeToCamelCase(message.t.toLowerCase())]?.(req.body.payload, req.body.shardId); res.status(200).json({ success: true }) }