2023-01-11 18:21:43 -08:00
|
|
|
import { Interaction, log, LT, Message } from '../deps.ts';
|
2023-01-11 15:06:20 -08:00
|
|
|
|
|
|
|
const jsonStringifyBig = (input: any) => {
|
|
|
|
return JSON.stringify(input, (_key, value) => typeof value === 'bigint' ? value.toString() + 'n' : value);
|
|
|
|
};
|
|
|
|
|
|
|
|
const genericLogger = (level: LT, message: string) => log(level, message);
|
2023-01-11 18:21:43 -08:00
|
|
|
const interactionSendError = (location: string, interaction: Interaction | string, err: Error) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to respond to interaction: ${jsonStringifyBig(interaction)} | Error: ${err.name} - ${err.message}`);
|
2023-01-11 15:06:20 -08:00
|
|
|
const messageEditError = (location: string, message: Message | string, err: Error) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to edit message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`);
|
|
|
|
const messageGetError = (location: string, message: Message | string, err: Error) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to get message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`);
|
|
|
|
const messageSendError = (location: string, message: Message | string, err: Error) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to send message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`);
|
|
|
|
const messageDeleteError = (location: string, message: Message | string, err: Error) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to delete message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`);
|
|
|
|
const reactionAddError = (location: string, message: Message | string, err: Error, emoji: string) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to add emoji (${emoji}) to message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`);
|
|
|
|
const reactionDeleteError = (location: string, message: Message | string, err: Error, emoji: string) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to delete emoji (${emoji}) from message: ${jsonStringifyBig(message)} | Error: ${err.name} - ${err.message}`);
|
2023-01-28 17:58:24 -08:00
|
|
|
const channelUpdateError = (location: string, message: string, err: Error) =>
|
|
|
|
genericLogger(LT.ERROR, `${location} | Failed to update channel | ${message} | Error: ${err.name} - ${err.message}`);
|
|
|
|
|
2023-01-11 15:06:20 -08:00
|
|
|
const dbError = (location: string, type: string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to ${type} database | Error: ${err.name} - ${err.message}`);
|
|
|
|
|
|
|
|
export default {
|
|
|
|
commonLoggers: {
|
2023-01-28 17:58:24 -08:00
|
|
|
channelUpdateError,
|
2023-01-11 15:06:20 -08:00
|
|
|
dbError,
|
2023-01-11 18:21:43 -08:00
|
|
|
interactionSendError,
|
2023-01-11 15:06:20 -08:00
|
|
|
messageGetError,
|
|
|
|
messageEditError,
|
|
|
|
messageSendError,
|
|
|
|
messageDeleteError,
|
|
|
|
reactionAddError,
|
|
|
|
reactionDeleteError,
|
|
|
|
},
|
|
|
|
jsonStringifyBig,
|
|
|
|
};
|