mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add Sharding Capabilities
This commit is contained in:
@@ -30,6 +30,8 @@ class InfoCommand extends commando.Command {
|
|||||||
if (seconds < 10) seconds = "0" + seconds;
|
if (seconds < 10) seconds = "0" + seconds;
|
||||||
return hours + ":" + minutes + ":" + seconds;
|
return hours + ":" + minutes + ":" + seconds;
|
||||||
};
|
};
|
||||||
|
let guilds = this.client.guilds.size;
|
||||||
|
let users = this.client.users.size;
|
||||||
const embed = new Discord.RichEmbed()
|
const embed = new Discord.RichEmbed()
|
||||||
.setTitle('Welcome to XiaoBot!')
|
.setTitle('Welcome to XiaoBot!')
|
||||||
.setAuthor(this.client.user.username, this.client.user.avatarURL)
|
.setAuthor(this.client.user.username, this.client.user.avatarURL)
|
||||||
@@ -41,17 +43,17 @@ class InfoCommand extends commando.Command {
|
|||||||
.addField('Commands',
|
.addField('Commands',
|
||||||
"There are a variety of commands XiaoBot can use! Use ';help' to view a list of all commands!")
|
"There are a variety of commands XiaoBot can use! Use ';help' to view a list of all commands!")
|
||||||
.addField('Servers',
|
.addField('Servers',
|
||||||
this.client.guilds.size, true)
|
guilds, true)
|
||||||
.addField('Users',
|
.addField('Users',
|
||||||
this.client.users.size, true)
|
users, true)
|
||||||
|
.addField('Shards',
|
||||||
|
this.client.options.shardCount + " (This is Shard: " + this.client.shard.id + ")", true)
|
||||||
.addField('Commands',
|
.addField('Commands',
|
||||||
config.commandcount, true)
|
config.commandcount, true)
|
||||||
.addField('Owner',
|
.addField('Owner',
|
||||||
"dragonfire535#8081", true)
|
"dragonfire535#8081", true)
|
||||||
.addField('Uptime',
|
.addField('Uptime',
|
||||||
toHHMMSS(process.uptime()), true)
|
toHHMMSS(process.uptime()), true)
|
||||||
.addField('Node Version',
|
|
||||||
"7.6.0", true)
|
|
||||||
.addField('Host',
|
.addField('Host',
|
||||||
"[Heroku](https://www.heroku.com/)", true)
|
"[Heroku](https://www.heroku.com/)", true)
|
||||||
.addField('Source Code',
|
.addField('Source Code',
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ client.on('message', (message) => {
|
|||||||
console.log(client.guilds.array().length + " Servers: " + client.guilds.map(g => g.name + " (" + g.id + ")").join(", "));
|
console.log(client.guilds.array().length + " Servers: " + client.guilds.map(g => g.name + " (" + g.id + ")").join(", "));
|
||||||
message.channel.sendMessage("Sent the information to the console!");
|
message.channel.sendMessage("Sent the information to the console!");
|
||||||
}
|
}
|
||||||
|
if(message.content.startsWith(';shards')) {
|
||||||
|
if(message.author.id !== config.owner) return;
|
||||||
|
message.channel.sendMessage(client.options.shardCount);
|
||||||
|
}
|
||||||
if(message.content.startsWith(';leave')) {
|
if(message.content.startsWith(';leave')) {
|
||||||
if(message.author.id !== config.owner) return;
|
if(message.author.id !== config.owner) return;
|
||||||
console.log("[Command] " + message.content);
|
console.log("[Command] " + message.content);
|
||||||
@@ -91,75 +95,15 @@ client.on('guildMemberRemove', member => {
|
|||||||
|
|
||||||
client.on('guildCreate', guild => {
|
client.on('guildCreate', guild => {
|
||||||
console.log("[Guild] I have joined the guild: " + guild.name + " (" + guild.id + ")...");
|
console.log("[Guild] I have joined the guild: " + guild.name + " (" + guild.id + ")...");
|
||||||
const carbonPOST = {
|
|
||||||
method: 'POST',
|
|
||||||
uri: 'https://www.carbonitex.net/discord/data/botdata.php',
|
|
||||||
body: {
|
|
||||||
key: config.carbonkey,
|
|
||||||
servercount: client.guilds.size
|
|
||||||
},
|
|
||||||
json: true
|
|
||||||
}
|
|
||||||
const DBotsPOST = {
|
|
||||||
method: 'POST',
|
|
||||||
uri: 'https://bots.discord.pw/api/bots/278305350804045834/stats',
|
|
||||||
body: {
|
|
||||||
server_count: client.guilds.size
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
'Authorization': config.botskey
|
|
||||||
},
|
|
||||||
json: true
|
|
||||||
}
|
|
||||||
request(carbonPOST).then(function (parsedBody) {
|
|
||||||
console.log('[Carbon] ' + parsedBody);
|
|
||||||
}).catch(function (err) {
|
|
||||||
console.log("[Carbon] " + err);
|
|
||||||
});
|
|
||||||
request(DBotsPOST).then(function (parsedBody) {
|
|
||||||
console.log('[Discord Bots] ' + parsedBody);
|
|
||||||
}).catch(function (err) {
|
|
||||||
console.log("[Discord Bots] " + err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('guildDelete', guild => {
|
client.on('guildDelete', guild => {
|
||||||
console.log("[Guild] I have left the guild: " + guild.name + " (" + guild.id + ")...");
|
console.log("[Guild] I have left the guild: " + guild.name + " (" + guild.id + ")...");
|
||||||
const carbonPOST = {
|
|
||||||
method: 'POST',
|
|
||||||
uri: 'https://www.carbonitex.net/discord/data/botdata.php',
|
|
||||||
body: {
|
|
||||||
key: config.carbonkey,
|
|
||||||
servercount: client.guilds.size
|
|
||||||
},
|
|
||||||
json: true
|
|
||||||
}
|
|
||||||
const DBotsPOST = {
|
|
||||||
method: 'POST',
|
|
||||||
uri: 'https://bots.discord.pw/api/bots/278305350804045834/stats',
|
|
||||||
body: {
|
|
||||||
server_count: client.guilds.size
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
'Authorization': config.botskey
|
|
||||||
},
|
|
||||||
json: true
|
|
||||||
}
|
|
||||||
request(carbonPOST).then(function (parsedBody) {
|
|
||||||
console.log('[Carbon] ' + parsedBody);
|
|
||||||
}).catch(function (err) {
|
|
||||||
console.log("[Carbon] " + err);
|
|
||||||
});
|
|
||||||
request(DBotsPOST).then(function (parsedBody) {
|
|
||||||
console.log('[Discord Bots] ' + parsedBody);
|
|
||||||
}).catch(function (err) {
|
|
||||||
console.log("[Discord Bots] " + err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.setInterval(()=>{
|
client.setInterval(()=>{
|
||||||
let games = ["with a cardboard box", "with Rem", "with my cat", "in the fridge", "in " + client.guilds.size + " servers", "with dragonfire535", "at the Inn", "with your heart", "with a knife", "with a murderous cow", ";help | dragonfire535", "with Cleverbot", "like a pirate", "with all my games", "against Miki", "with " + client.users.size + " Users"][Math.floor(Math.random() * 16)];
|
let games = ["with a cardboard box", "with Rem", "with my cat", "in the fridge", "in ", " servers", "with dragonfire535", "at the Inn", "with your heart", "with a knife", "with a murderous cow", ";help | dragonfire535", "with Cleverbot", "like a pirate", "with all my games", "against Miki"][Math.floor(Math.random() * 14)];
|
||||||
client.user.setGame(games);
|
Manager.broadcastEval("client.user.setGame(games)");
|
||||||
}, 300000);
|
}, 300000);
|
||||||
|
|
||||||
client.once('ready', () => {
|
client.once('ready', () => {
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"name": "XiaoBot",
|
"name": "XiaoBot",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "shardingmanager.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
const Discord = require('discord.js');
|
||||||
|
const Manager = new Discord.ShardingManager('./index.js');
|
||||||
|
Manager.spawn(1);
|
||||||
Reference in New Issue
Block a user