Skip to content

Commit

Permalink
Add additional server start options
Browse files Browse the repository at this point in the history
  • Loading branch information
synzen committed Dec 28, 2018
1 parent d300b52 commit 684e8d5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -11,6 +11,8 @@
"scripts": {
"start": "node server.js",
"dev": "node -r dotenv/config server.js",
"dev-sharded": "node -r dotenv/config server-manager.js",
"dev-client": "node -r dotenv/config server-client.js",
"eslint": "eslint --fix ."
},
"dependencies": {
Expand Down
10 changes: 10 additions & 0 deletions server-client.js
@@ -0,0 +1,10 @@
// Create a single client

const DiscordRSS = require('./index.js')
const drss = new DiscordRSS.Client() // Override default config values here

drss.login(require('./config.js').bot.token, true)

drss.on('finishInit', () => {
// Do whatever once the bot has finished initialization
})
12 changes: 12 additions & 0 deletions server-manager.js
@@ -0,0 +1,12 @@
// Only create the Sharding Manager

const DiscordRSS = require('./index.js')
const Discord = require('discord.js')
const shardingManager = new Discord.ShardingManager('./server-shard.js', { respawn: false })
const shardedDiscordRSSClient = new DiscordRSS.ClientSharded(shardingManager, { readFileSchedules: true, setPresence: true, forceSharded: true })

shardedDiscordRSSClient.run()

shardedDiscordRSSClient.on('finishInit', () => {
// Do whatever once the sharding manager has finished spawning and waiting for all shards to finish initialization
})
6 changes: 6 additions & 0 deletions server-shard.js
@@ -0,0 +1,6 @@
// Create a single client

const DiscordRSS = require('./index.js')
const drss = new DiscordRSS.Client() // Override default config values here

drss.login(require('./config.js').bot.token, true)
2 changes: 2 additions & 0 deletions server.js
@@ -1,3 +1,5 @@
// 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

const DiscordRSS = require('./index.js')
const config = require('./config.js')

Expand Down

0 comments on commit 684e8d5

Please sign in to comment.