mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
logging part 2
This commit is contained in:
parent
416b89c6ce
commit
5b84b9a70a
2 changed files with 34 additions and 8 deletions
3
index.js
3
index.js
|
@ -18,6 +18,8 @@ const manager = new ClusterManager(client, token, {
|
|||
|
||||
(async () => {
|
||||
console.log(`v2 | starting v2.`)
|
||||
|
||||
// Logging
|
||||
manager.on("clusterProcess", ({ clusterProcess }) => {
|
||||
clusterProcess.on('close', ({code, signal}) => {
|
||||
basecamp(`<:ico_w4:1086624964284788787>\`[${process.env.HOSTNAME}]\` **\` CLUSTER_CLOSED \`** Cluster ${clusterProcess.clusterId} closed with code \`${code}\` and signal \`${signal}\` @ \`${Date.now()}\``)
|
||||
|
@ -27,6 +29,7 @@ const manager = new ClusterManager(client, token, {
|
|||
await basecamp(`\`\`\`js\n${error}\`\`\``)
|
||||
});
|
||||
})
|
||||
|
||||
await manager.run();
|
||||
console.log(`v2 | ready. took ${(Date.now() - time) / 1000}.`)
|
||||
})();
|
|
@ -1,5 +1,5 @@
|
|||
const { Constants, ClusterClient, CommandClient, InteractionCommandClient } = require('detritus-client');
|
||||
const { ActivityTypes, PresenceStatuses, GatewayIntents, Permissions } = require('detritus-client/lib/constants');
|
||||
const { ActivityTypes, PresenceStatuses, GatewayIntents, Permissions, ClientEvents } = require('detritus-client/lib/constants');
|
||||
|
||||
const Paginator = require('./paginator').PaginatorCluster
|
||||
|
||||
|
@ -52,7 +52,7 @@ const interactionClient = new InteractionCommandClient(cluster, {
|
|||
useClusterClient: true
|
||||
})
|
||||
|
||||
const { maintower } = require('./logging');
|
||||
const { maintower, basecamp } = require('./logging');
|
||||
const { icon, highlight } = require('./utils/markdown');
|
||||
const { editOrReply } = require('./utils/message');
|
||||
|
||||
|
@ -124,11 +124,34 @@ commandClient.on('commandRunError', async ({context, error}) => {
|
|||
});
|
||||
|
||||
(async () => {
|
||||
await cluster.run();
|
||||
await commandClient.addMultipleIn('../commands/message/');
|
||||
await commandClient.run()
|
||||
|
||||
await interactionClient.addMultipleIn('../commands/interaction/context');
|
||||
await interactionClient.addMultipleIn('../commands/interaction/slash');
|
||||
await interactionClient.run();
|
||||
// Logging
|
||||
cluster.on(ClientEvents.REST_RESPONSE, async ({response, restRequest, shard}) => {
|
||||
const route = response.request.route;
|
||||
if (route) {
|
||||
if (!response.ok) {
|
||||
const message = `Shard #${shard.shardId}: (NOT OK) ${response.statusCode} ${response.request.method}-${response.request.url} (${route.path})`;
|
||||
console.log(message);
|
||||
console.log(await response.text());
|
||||
await basecamp(`<:ico_w3:1086624963047460874>\`[${process.env.HOSTNAME}]\` **\` SHARD_REST_ERROR \`** Shard ${shard.shardId} received request error \`${response.statusCode}\` @ \`${Date.now()}\`\n\` ${response.request.method} \` \`${response.request.url}\` (${route.path})\n\`\`\`js\n${await response.text()}\`\`\``)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cluster.on(ClientEvents.WARN, async ({error}) => {
|
||||
await basecamp(`<:ico_w2:1086624961025810485>\`[${process.env.HOSTNAME}]\` **\` CLUSTER_WARNING \`** Cluster ${cluster.manager.clusterId} reported warning @ \`${Date.now()}\`:\n\`\`\`${error}\`\`\``)
|
||||
});
|
||||
|
||||
try{
|
||||
await cluster.run();
|
||||
await commandClient.addMultipleIn('../commands/message/');
|
||||
await commandClient.run()
|
||||
|
||||
await interactionClient.addMultipleIn('../commands/interaction/context');
|
||||
await interactionClient.addMultipleIn('../commands/interaction/slash');
|
||||
await interactionClient.run();
|
||||
} catch(e){
|
||||
console.log(e)
|
||||
console.log(e.errors)
|
||||
}
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue