feat: improve error handling

This commit is contained in:
Isaac
2023-06-25 13:41:07 +01:00
parent 47fc7bde43
commit e8b95a2f31
10 changed files with 165 additions and 23 deletions

View File

@@ -3,6 +3,11 @@ const {
EmbedBuilder,
} = require('discord.js');
const { diff: getDiff } = require('object-diffy');
const ShortUniqueId = require('short-unique-id');
const uid = new ShortUniqueId();
const getSUID = () => uid.stamp(10);
const uuidRegex = /[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/g;
@@ -235,6 +240,7 @@ async function logMessageEvent(client, {
module.exports = {
getLogChannel,
getSUID,
logAdminEvent,
logMessageEvent,
logTicketEvent,

View File

@@ -28,6 +28,7 @@ const {
decrypt,
encrypt,
} = new Cryptr(process.env.ENCRYPTION_KEY);
const { getSUID } = require('../logging');
/**
* @typedef {import('@prisma/client').Category &
@@ -682,7 +683,7 @@ module.exports = class TicketManager {
userId: interaction.user.id,
});
} catch (error) {
const ref = require('crypto').randomUUID();
const ref = getSUID();
this.client.log.warn.tickets('An error occurred whilst creating ticket', channel.id);
this.client.log.error.tickets(ref);
this.client.log.error.tickets(error);