Skip to content

Commit

Permalink
Created a sharded-client script.
Browse files Browse the repository at this point in the history
  • Loading branch information
moonstar-x committed Jan 19, 2022
1 parent aca6352 commit ab15cd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dev": "nodemon --exec npm start",
"lint:errors-only": "node_modules/.bin/eslint src --quiet",
"lint": "node_modules/.bin/eslint src",
"deploy": "node ./src/command-deployer.js"
"deploy": "node ./src/command-deployer.js",
"start-sharded": "node ./src/sharded-client.js"
},
"engines": {
"node": ">=16.6"
Expand Down
21 changes: 21 additions & 0 deletions src/sharded-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');
const logger = require('@greencoast/logger');
const { ShardingManager } = require('discord.js');
const { ConfigProvider } = require('@greencoast/discord.js-extended');

// Just need the token in here, the rest will be handled by the actual client.
const config = new ConfigProvider({
env: process.env,
configPath: path.join(__dirname, '../config/settings.json'),
types: {
TOKEN: 'string'
}
});

const manager = new ShardingManager(path.join(__dirname, './app.js'), { token: config.get('TOKEN') });

manager.on('shardCreate', (shard) => {
logger.info(`Launched shard with ID: ${shard.id}`);
});

manager.spawn({ amount: 2 });

0 comments on commit ab15cd0

Please sign in to comment.