add maintower logging to interaction commands

This commit is contained in:
bignutty 2024-07-14 17:10:46 +02:00
parent 177a9cd990
commit 265c8793ca

View file

@ -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