Skip to content

Commit 684e8d5

Browse files
committed
Add additional server start options
1 parent d300b52 commit 684e8d5

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"scripts": {
1212
"start": "node server.js",
1313
"dev": "node -r dotenv/config server.js",
14+
"dev-sharded": "node -r dotenv/config server-manager.js",
15+
"dev-client": "node -r dotenv/config server-client.js",
1416
"eslint": "eslint --fix ."
1517
},
1618
"dependencies": {

server-client.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Create a single client
2+
3+
const DiscordRSS = require('./index.js')
4+
const drss = new DiscordRSS.Client() // Override default config values here
5+
6+
drss.login(require('./config.js').bot.token, true)
7+
8+
drss.on('finishInit', () => {
9+
// Do whatever once the bot has finished initialization
10+
})

server-manager.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Only create the Sharding Manager
2+
3+
const DiscordRSS = require('./index.js')
4+
const Discord = require('discord.js')
5+
const shardingManager = new Discord.ShardingManager('./server-shard.js', { respawn: false })
6+
const shardedDiscordRSSClient = new DiscordRSS.ClientSharded(shardingManager, { readFileSchedules: true, setPresence: true, forceSharded: true })
7+
8+
shardedDiscordRSSClient.run()
9+
10+
shardedDiscordRSSClient.on('finishInit', () => {
11+
// Do whatever once the sharding manager has finished spawning and waiting for all shards to finish initialization
12+
})

server-shard.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Create a single client
2+
3+
const DiscordRSS = require('./index.js')
4+
const drss = new DiscordRSS.Client() // Override default config values here
5+
6+
drss.login(require('./config.js').bot.token, true)

server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// This logic that stems from this file will automatically create a sharding manager and shards if necessary, if the original client cannot handle the number of guilds
2+
13
const DiscordRSS = require('./index.js')
24
const config = require('./config.js')
35

0 commit comments

Comments
 (0)