mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 21:53:07 -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 () => {
|
(async () => {
|
||||||
console.log(`v2 | starting v2.`)
|
console.log(`v2 | starting v2.`)
|
||||||
|
|
||||||
|
// Logging
|
||||||
manager.on("clusterProcess", ({ clusterProcess }) => {
|
manager.on("clusterProcess", ({ clusterProcess }) => {
|
||||||
clusterProcess.on('close', ({code, signal}) => {
|
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()}\``)
|
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 basecamp(`\`\`\`js\n${error}\`\`\``)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
await manager.run();
|
await manager.run();
|
||||||
console.log(`v2 | ready. took ${(Date.now() - time) / 1000}.`)
|
console.log(`v2 | ready. took ${(Date.now() - time) / 1000}.`)
|
||||||
})();
|
})();
|
|
@ -1,5 +1,5 @@
|
||||||
const { Constants, ClusterClient, CommandClient, InteractionCommandClient } = require('detritus-client');
|
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
|
const Paginator = require('./paginator').PaginatorCluster
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ const interactionClient = new InteractionCommandClient(cluster, {
|
||||||
useClusterClient: true
|
useClusterClient: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const { maintower } = require('./logging');
|
const { maintower, basecamp } = require('./logging');
|
||||||
const { icon, highlight } = require('./utils/markdown');
|
const { icon, highlight } = require('./utils/markdown');
|
||||||
const { editOrReply } = require('./utils/message');
|
const { editOrReply } = require('./utils/message');
|
||||||
|
|
||||||
|
@ -124,11 +124,34 @@ commandClient.on('commandRunError', async ({context, error}) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await cluster.run();
|
|
||||||
await commandClient.addMultipleIn('../commands/message/');
|
|
||||||
await commandClient.run()
|
|
||||||
|
|
||||||
await interactionClient.addMultipleIn('../commands/interaction/context');
|
// Logging
|
||||||
await interactionClient.addMultipleIn('../commands/interaction/slash');
|
cluster.on(ClientEvents.REST_RESPONSE, async ({response, restRequest, shard}) => {
|
||||||
await interactionClient.run();
|
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