From ab42b4f91bbe69906005bf8220fae0878ea02f93 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:39:46 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fixed=20som?= =?UTF-8?q?e=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/command/index.ts | 4 ---- src/managers/event/index.ts | 2 ++ .../commands/counters/modules/view/index.ts | 7 ------- .../modules/credits/modules/transfer/index.ts | 19 ++++--------------- .../modules/roles/modules/cancel/index.ts | 3 --- 5 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts index 5f43be4..10e6184 100644 --- a/src/managers/command/index.ts +++ b/src/managers/command/index.ts @@ -23,10 +23,6 @@ export const register = async (client: Client) => { throw new Error( `📦 No command builder found while importing "${commandName}"` ); - if (!command.execute) - throw new Error( - `📦 No command execute found while importing "${commandName}"` - ); if (!command.moduleData) throw new Error( `📦 No command moduleData found while importing "${commandName}"` diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index c0734ba..778066d 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -44,6 +44,8 @@ export const register = async (client: Client) => { case "on": client.on(eventName, eventExecutor); break; + default: + logger.error(`${eventName} does not have a valid type`); } importedEventAmount += 1; }; diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 679b68e..321206c 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -46,13 +46,6 @@ export default { channelId: discordChannel.id, }); - const counters = await counterSchema.find(); - - console.log(counters, { - guildId: guild.id, - channelId: discordChannel.id, - }); - if (!counter) throw new Error("No counter found for channel"); return interaction.editReply({ diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index 2d790b8..62a9425 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -207,24 +207,13 @@ export default { await toUser.save(); await session.commitTransaction(); - } catch (error) { + } catch (error: unknown) { await session.abortTransaction(); session.endSession(); - logger.error(`${error}`); - return interaction.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription( - "An error occurred while trying to gift credits. Please try again." - ) - .setColor(errorColor) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error( + "An error occurred while trying to gift credits. Please try again later." + ); } finally { // ending the session session.endSession(); diff --git a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts index a2d92d2..f3064cd 100644 --- a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts @@ -79,9 +79,6 @@ export default { return interaction?.editReply({ embeds: [interactionEmbed], }); - }) - .catch(async (error: Error) => { - return logger?.silly(`Role could not be deleted. ${error}`); }); }, };