From 265c8793ca001f11f94e5c101ab89984b2cbdd28 Mon Sep 17 00:00:00 2001 From: bignutty <3515180-bignutty@users.noreply.gitlab.com> Date: Sun, 14 Jul 2024 17:10:46 +0200 Subject: [PATCH] add maintower logging to interaction commands --- labscore/client.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/labscore/client.js b/labscore/client.js index 641646b..2047212 100644 --- a/labscore/client.js +++ b/labscore/client.js @@ -158,6 +158,40 @@ commandClient.on('commandRunError', async ({context, error}) => { } }); + +interactionClient.on('commandRunError', async ({context, error}) => { + try{ + // Log the error via our maintower service + let packages = { + data: {}, + origin: {}, + meta: { + shard: context.shardId.toString(), + cluster: context.manager.clusterId.toString() + } + } + + if(context.user) packages.origin.user = { name: `${context.user.username}#${context.user.discriminator}`, id: context.user.id } + if(context.guild) packages.origin.guild = { name: context.guild.name, id: context.guild.id } + if(context.channel) packages.origin.channel = { name: context.channel.name, id: context.channel.id } + + packages.data.command = context.command.name + packages.data.error = error ? error.stack || error.message : error + if(error.raw) packages.data.raw = JSON.stringify(error.raw, null, 2) + + let req = await maintower(packages, "01") + + await editOrReply(context, { + content: `${icon("cross")} Something went wrong while attempting to run this command. (Reference: \`${req}\`)` + }) + }catch(e){ + console.log(e) + await editOrReply(context, { + content: `${icon("cross")} Something went wrong while attempting to run this command.` + }) + } +}); + (async () => { // Logging