From 038b8070f9165e2a2ff15e90c3719b3259b3d5c3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 12:50:16 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fixed?= =?UTF-8?q?=20some=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/manage/modules/credits/index.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/commands/manage/modules/credits/index.ts b/src/plugins/commands/manage/modules/credits/index.ts index 0ed9837..bf6f578 100644 --- a/src/plugins/commands/manage/modules/credits/index.ts +++ b/src/plugins/commands/manage/modules/credits/index.ts @@ -1,6 +1,5 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; - import modules from "./modules"; export const moduleData = modules; @@ -19,14 +18,21 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "give": - return modules.give.execute(interaction); + await modules.give.execute(interaction); + break; case "set": - return modules.set.execute(interaction); + await modules.set.execute(interaction); + break; case "take": - return modules.take.execute(interaction); + await modules.take.execute(interaction); + break; case "transfer": - return modules.transfer.execute(interaction); + await modules.transfer.execute(interaction); + break; case "giveaway": - return modules.giveaway.execute(interaction); + await modules.giveaway.execute(interaction); + break; + default: + throw new Error("No module found for that specific command"); } }; From a5a4aa93b8b2c31551c5e53c2ece7ad7ab4f6f76 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 12:52:17 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix=20m?= =?UTF-8?q?ore=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/config/index.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/plugins/commands/config/index.ts b/src/plugins/commands/config/index.ts index 5d9fd42..783219b 100644 --- a/src/plugins/commands/config/index.ts +++ b/src/plugins/commands/config/index.ts @@ -1,6 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; - import modules from "./modules"; export const builder = new SlashCommandBuilder() @@ -20,18 +19,27 @@ export const moduleData = modules; export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options?.getSubcommand()) { case "cpgg": - return modules.cpgg.execute(interaction); + await modules.cpgg.execute(interaction); + break; case "credits": - return modules.credits.execute(interaction); + await modules.credits.execute(interaction); + break; case "points": - return modules.points.execute(interaction); + await modules.points.execute(interaction); + break; case "welcome": - return modules.welcome.execute(interaction); + await modules.welcome.execute(interaction); + break; case "audits": - return modules.audits.execute(interaction); + await modules.audits.execute(interaction); + break; case "shop": - return modules.shop.execute(interaction); + await modules.shop.execute(interaction); + break; case "embeds": - return modules.embeds.execute(interaction); + await modules.embeds.execute(interaction); + break; + default: + throw new Error("No module found for that specific command."); } }; From 9baa207df9ccccdbe94f002158912dd8e32ea65c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 12:53:00 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=9A=91=20spelled=20throw=20wrong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/credits/modules/gift/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index 0f36ee9..ca2f554 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -3,7 +3,7 @@ import { ChatInputCommandInteraction, EmbedBuilder, - SlashCommandSubcommandBuilder + SlashCommandSubcommandBuilder, } from "discord.js"; import mongoose from "mongoose"; // Configurations @@ -201,7 +201,9 @@ export default { await session.abortTransaction(); session.endSession(); - thorw new Error("An error occurred while trying to gift credits. Please try again later.") + throw new Error( + "An error occurred while trying to gift credits. Please try again later." + ); } finally { // ending the session session.endSession();