mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +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;
|
||||
return hours + ":" + minutes + ":" + seconds;
|
||||
};
|
||||
let guilds = this.client.guilds.size;
|
||||
let users = this.client.users.size;
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setTitle('Welcome to XiaoBot!')
|
||||
.setAuthor(this.client.user.username, this.client.user.avatarURL)
|
||||
@@ -41,17 +43,17 @@ class InfoCommand extends commando.Command {
|
||||
.addField('Commands',
|
||||
"There are a variety of commands XiaoBot can use! Use ';help' to view a list of all commands!")
|
||||
.addField('Servers',
|
||||
this.client.guilds.size, true)
|
||||
guilds, true)
|
||||
.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',
|
||||
config.commandcount, true)
|
||||
.addField('Owner',
|
||||
"dragonfire535#8081", true)
|
||||
.addField('Uptime',
|
||||
toHHMMSS(process.uptime()), true)
|
||||
.addField('Node Version',
|
||||
"7.6.0", true)
|
||||
.addField('Host',
|
||||
"[Heroku](https://www.heroku.com/)", true)
|
||||
.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(", "));
|
||||
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.author.id !== config.owner) return;
|
||||
console.log("[Command] " + message.content);
|
||||
@@ -91,75 +95,15 @@ client.on('guildMemberRemove', member => {
|
||||
|
||||
client.on('guildCreate', guild => {
|
||||
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 => {
|
||||
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(()=>{
|
||||
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)];
|
||||
client.user.setGame(games);
|
||||
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)];
|
||||
Manager.broadcastEval("client.user.setGame(games)");
|
||||
}, 300000);
|
||||
|
||||
client.once('ready', () => {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "XiaoBot",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"main": "shardingmanager.js",
|
||||
"scripts": {
|
||||
"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