Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit fb99e87

Browse files
committed
code by @shrams - added sharding manager
1 parent 15f6438 commit fb99e87

File tree

6 files changed

+18
-34
lines changed

6 files changed

+18
-34
lines changed

.vscode/launch.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ COPY src $APP/src
1818

1919
WORKDIR $APP
2020

21-
CMD [ "pm2-runtime", "src/index.js" ]
21+
CMD [ "pm2-runtime", "src/ShardingMgr.js" ]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "psybot",
33
"version": "1.0.0",
4-
"main": "src/index.js",
4+
"main": "src/ShardingMgr.js",
55
"keywords": [
66
"discord",
77
"bot",
@@ -19,7 +19,7 @@
1919
},
2020
"scripts": {
2121
"prestart": "npm install",
22-
"start": "node src/index.js"
22+
"start": "node src/ShardingMgr.js"
2323
},
2424
"author": "void*",
2525
"license": "GPLv3",

src/Bot.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Bot extends Commando.Client {
99
constructor(token, ownerid, commandprefix) {
1010
super({
1111
"owner": (ownerid) ? ownerid : null,
12-
"commandPrefix": (commandprefix) ? commandprefix : '$',
12+
"commandPrefix": (commandprefix) ? commandprefix : '-',
1313
"intents": myIntents
1414
});
1515
this.token = token;
@@ -28,7 +28,6 @@ class Bot extends Commando.Client {
2828
});
2929

3030
this
31-
.on("debug", console.log)
3231
.on("warn", console.log)
3332

3433
// register default groups and commands

src/ShardingMgr.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const configName = process.env.CONFIG_NAME || 'config.json';
2+
const config = require('./' + configName);
3+
4+
const {ShardingManager} = require('discord.js');
5+
6+
const manager = new ShardingManager('./src/index.js', {
7+
totalShards: 'auto',
8+
token: config.general.token
9+
});
10+
11+
manager.on('shardCreate', (shard) => console.log(`Shard ${shard.id} launched`));
12+
13+
manager.spawn();

src/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"general" : {
33
"token" : "",
44
"ownerID" : [""],
5-
"globalCommandPrefix" : "",
5+
"globalCommandPrefix" : "-",
66
"deleteCommandMessages" : false
77
}
88
}

0 commit comments

Comments
 (0)