From a1b9fdcd4e54aeb038f4f82236456c3927b9fc41 Mon Sep 17 00:00:00 2001 From: Anthony Berg Date: Fri, 12 Jan 2024 00:05:41 +0000 Subject: [PATCH] feat(arabot): start listeners for error logging --- src/listeners/error.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/utils/errorHandlers.ts | 18 ++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/listeners/error.ts create mode 100644 src/utils/errorHandlers.ts diff --git a/src/listeners/error.ts b/src/listeners/error.ts new file mode 100644 index 0000000..2ca55f8 --- /dev/null +++ b/src/listeners/error.ts @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + Animal Rights Advocates Discord Bot + Copyright (C) 2024 Anthony Berg + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import { Listener, ListenerErrorPayload } from '@sapphire/framework'; + +export class ErrorListener extends Listener { + public constructor( + context: Listener.LoaderContext, + options: Listener.Options, + ) { + super(context, { + ...options, + event: 'listenerError', + }); + } + + public run(error: Error, payload: ListenerErrorPayload) { + this.container.logger.debug( + `TEST ERROR: ${error.stack}\n\nPAYLOAD: ${payload.piece.name}`, + ); + } +} diff --git a/src/utils/errorHandlers.ts b/src/utils/errorHandlers.ts new file mode 100644 index 0000000..bf43ca8 --- /dev/null +++ b/src/utils/errorHandlers.ts @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + Animal Rights Advocates Discord Bot + Copyright (C) 2024 Anthony Berg + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/