我想在我的硬性管理人(服务器)中建立一个人才库,然后通过硬程序(机器人)。 这里是我的hard夫经理(服务器):
var clientMysqlEvent = require( ./database/botpool.js ).connection;
const flatted = require( flatted );
const clientMysqlEventserialized = flatted.stringify(clientMysqlEvent);
const { ShardingManager } = require( discord.js );
const shard = new ShardingManager( ./bot.js , {
token: config.token,
respawn: true,
});
shard.spawn({ amount: splen, delay: 100, timeout: 120000 });
//console.log(`[DEBUG/SHARD] Shard ${shard.id} connected to Discord s Gateway.`)
// Sending the data to the shard.
shard.on("ready", () => {
console.log(`[SHARD] Shard ${formatedShardId} connected to Discord s Gateway.`)
// Sending the data to the shard.
shard.send({type: "shardId", data: {shardId: shard.id, shardTotal: splen}});
shard.send({type: "myDb", data: {dbManager: clientMysqlEventserialized}});
});
底部:
const mysql = require( mysql );
var connection = mysql.createPool({
connectionLimit : 20,
host : localhost ,
user : user ,
password : pass ,
database : db
});
connection.on( release , function (connection1) {
console.log( BOT: Connection %d released , connection1.threadId);
});
connection.on( acquire , function (connection1) {
console.log( BOT: Connection %d acquired , connection1.threadId);
});
connection.on( connection , function (connection1) {
console.log( BOT: Connection %d connected , connection1.threadId);
});
connection.on( enqueue , function () {
console.log( BOT: Waiting for available connection slot );
});
exports.connection = connection;
伊斯兰教进程(下院):
const flatted = require( flatted );
var mysql = null;
process.on( message , message => {
if (!message.type) return false;
if (message.type == "shardId") {
console.log(`The shard id is: ${message.data.shardId + Number(1)}`);
console.log(`Total shard number is: ${message.data.shardTotal}`)
clientShardId = message.data.shardId + Number(1)
totalShardIds = message.data.shardTotal
console.log("Captured data: "+clientShardId+"/"+totalShardIds)
client.user.setPresence({ activities: [{ name: `${config.activities} [${message.data.shardId + Number(1)} / ${message.data.shardTotal}]` }] });
} else if (message.type == "myDb") {
//mysql = message.data.dbManager;
mysql = flatted.parse(message.data.dbManager);
//console.log("mysql:")
//console.log(mysql)
};
})
令人痛心的是,这种做法没有做我所想要的,而艰难的过程(下士)却创造了自己的人才。