mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix: Closes #3011 guide fixes
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user