mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 17:30:07 +00:00
Merge branch 'main' of https://github.com/discordeno/discordeno
This commit is contained in:
@@ -5,7 +5,7 @@ sidebar_label: Step 3 - Gateway
|
||||
|
||||
# Standalone Gateway
|
||||
|
||||
Sweet, it is time to start our gateway code. By now, you should have already built your rest process, as we will need it shortly.
|
||||
Sweet, it is time to start our gateway code. By now, you should have already built your rest process, as we will need it shortly. The gateway portion is the hardest and most complex part of making a bot. This is where most of your time will be spent to optimize your setup.
|
||||
|
||||
## Understanding The Concepts
|
||||
|
||||
@@ -116,11 +116,13 @@ Now, let's go ahead and set up the server where we will receive this and start a
|
||||
Just like before, we are going to make another http listener to listen for incoming events and delegate them outwords. Make a file called `services/gateway/sharding/index.ts`
|
||||
|
||||
```ts
|
||||
import { DiscordenoShard } from '@discordeno/gateway'
|
||||
import events from './events.js'
|
||||
import dotenv from 'dotenv'
|
||||
import express from 'express'
|
||||
dotenv.config()
|
||||
import { DiscordenoShard } from '@discordeno/gateway';
|
||||
import { logger } from '@discordeno/utils';
|
||||
import { Intents } from '@discordeno/types';
|
||||
import events from './events.js';
|
||||
import dotenv from 'dotenv';
|
||||
import express from 'express';
|
||||
dotenv.config();
|
||||
|
||||
const AUTHORIZATION = process.env.AUTHORIZATION as string
|
||||
const SHARDS = new Collection<number, DiscordenoShard>()
|
||||
@@ -144,23 +146,21 @@ app.all('/*', async (req, res) => {
|
||||
// Identify A Shard
|
||||
switch (req.body.type) {
|
||||
case 'IDENTIFY_SHARD': {
|
||||
logger.info(`[Shard] identifying ${SHARDS.has(req.body.shardId) ? 'existing' : 'new'} shard (${shardId})`)
|
||||
const shard =
|
||||
SHARDS.get(req.body.shardId) ??
|
||||
new DiscordenoShard({
|
||||
id: shardId,
|
||||
connection: {
|
||||
compress: this.compress,
|
||||
intents: this.intents,
|
||||
properties: this.properties,
|
||||
token: this.token,
|
||||
totalShards: this.totalShards,
|
||||
url: this.url,
|
||||
version: this.version,
|
||||
},
|
||||
// TODO: Enable this in the next portion of the guide.
|
||||
// events,
|
||||
})
|
||||
logger.info(`[Shard] identifying ${SHARDS.has(req.body.shardId) ? 'existing' : 'new'} shard (${shardId})`);
|
||||
const shard = SHARDS.get(req.body.shardId) ?? new DiscordenoShard({
|
||||
id: shardId,
|
||||
connection: {
|
||||
compress: req.body.compress,
|
||||
intents: req.body.intents,
|
||||
properties: req.body.properties,
|
||||
token: req.body.token,
|
||||
totalShards: req.body.totalShards,
|
||||
url: req.body.url,
|
||||
version: req.body.version,
|
||||
},
|
||||
// TODO: Enable this in the next portion of the guide.
|
||||
// events,
|
||||
});
|
||||
|
||||
SHARDS.set(shard.id, shard)
|
||||
await shard.identify()
|
||||
|
||||
@@ -75,3 +75,5 @@ Currently, there are a few issues with the migration.
|
||||
- `voice` - Currently **@discordeno/client** does not support voice features. Until we have a large music bot with the desire to migrate to discordeno we don't plan to support this as it is a massive endeavor. It will require a willing developer with good ability to test our implementation and make sure it scales well, like the rest of discordeno. If you are a music bot developer looking to migrate, and are willing to work with us to support this, please do contact me on Discord.
|
||||
- `selfbots/userbots` - Eris supported a lot of selfbot features that Discordeno does not. All of these features were removed. If you are trying to migrate a self bot, you will not be able to access a lot of features. This will never be supported. Please don't ask.
|
||||
- `command frameworks` - If you made your bot with a command framework package such as Yuuko, you may have some issues. This is because that package itself depends on Eris. It would need updating to support **@discordeno/client** instead of Eris. In a near future, when both typescript and node.js, you will be able to use *import maps* to replace all instance of eris with discordeno in all your packages.
|
||||
- `deprecations` - If your bot was written using old code that Eris had marked as deprecated, we removed that behavior. Take this time, to fix those few errors in the new cleaner fashion. The following is a list of reported methods that were effected:
|
||||
- getMessages
|
||||
|
||||
Reference in New Issue
Block a user