diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index 20b5445..5b920ba 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -151,9 +151,7 @@ export default { // Save toUser await toUser?.save()?.then(async () => { - logger?.silly(`Saved toUser`); - - return interaction?.editReply({ + await interaction?.editReply({ embeds: [ new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") @@ -165,6 +163,7 @@ export default { .setFooter({ text: footerText, iconURL: footerIcon }), ], }); + return; }); }, }; diff --git a/src/plugins/commands/moderation/index.ts b/src/plugins/commands/moderation/index.ts index c9a2bec..e74193e 100644 --- a/src/plugins/commands/moderation/index.ts +++ b/src/plugins/commands/moderation/index.ts @@ -10,13 +10,17 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.prune.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { - case "prune": - return modules.prune.execute(interaction); - default: + case "prune": { + await modules.prune.execute(interaction); + break; + } + default: { throw new Error( `Unknown subcommand: ${interaction.options.getSubcommand()}` ); + } } }; diff --git a/src/plugins/commands/profile/index.ts b/src/plugins/commands/profile/index.ts index 3a9305e..fb3f287 100644 --- a/src/plugins/commands/profile/index.ts +++ b/src/plugins/commands/profile/index.ts @@ -6,7 +6,6 @@ import { ChatInputCommandInteraction } from "discord.js"; import modules from "../../commands/profile/modules"; // Handlers -import logger from "../../../middlewares/logger"; export const moduleData = modules; @@ -16,14 +15,17 @@ export const builder = new SlashCommandBuilder() .setDescription("Check a profile.") .addSubcommand(modules.view.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; - if (options?.getSubcommand() === "view") { - logger?.silly(`Executing view subcommand`); - - return modules.view.execute(interaction); + switch (options.getSubcommand()) { + case "view": { + await modules.view.execute(interaction); + break; + } + default: { + throw new Error("Could not find module for that command"); + } } - - logger?.silly(`No subcommand found`); }; diff --git a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts index dc0be04..8e3b913 100644 --- a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts +++ b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts @@ -1,6 +1,6 @@ import { User } from "discord.js"; -export default async (to: User | null, from: User | null) => { +export default (to: User | null, from: User | null) => { if (from?.id === to?.id) { throw new Error("You cannot give reputation to yourself."); } diff --git a/src/plugins/commands/shop/index.ts b/src/plugins/commands/shop/index.ts index 5f6e0b6..1da2442 100644 --- a/src/plugins/commands/shop/index.ts +++ b/src/plugins/commands/shop/index.ts @@ -6,7 +6,6 @@ import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; // Handlers -import logger from "../../../middlewares/logger"; export const moduleData = modules; @@ -17,20 +16,27 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.cpgg.builder) .addSubcommandGroup(modules.roles.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; - if (options?.getSubcommand() === "cpgg") { - logger.silly(`Executing cpgg subcommand`); - - return modules.cpgg.execute(interaction); + switch (options.getSubcommand()) { + case "cpgg": { + await modules.cpgg.execute(interaction); + break; + } + default: { + throw new Error("Could not find module for that command."); + } } - if (options?.getSubcommandGroup() === "roles") { - logger?.silly(`Subcommand group is roles`); - - return modules.roles.execute(interaction); + switch (options.getSubcommandGroup()) { + case "roles": { + await modules.roles.execute(interaction); + break; + } + default: { + throw new Error("Could not find module for that command."); + } } - - logger?.silly(`No subcommand found.`); }; diff --git a/src/plugins/commands/utility/index.ts b/src/plugins/commands/utility/index.ts index a10fde2..fb87528 100644 --- a/src/plugins/commands/utility/index.ts +++ b/src/plugins/commands/utility/index.ts @@ -13,16 +13,21 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.avatar.builder) .addSubcommand(modules.ping.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "about": - return modules.about.execute(interaction); + await modules.about.execute(interaction); + break; case "stats": - return modules.stats.execute(interaction); + await modules.stats.execute(interaction); + break; case "avatar": - return modules.avatar.execute(interaction); + await modules.avatar.execute(interaction); + break; case "ping": - return modules.ping.execute(interaction); + await modules.ping.execute(interaction); + break; default: throw new Error( `Unknown subcommand: ${interaction.options.getSubcommand()}` diff --git a/src/plugins/events/guildMemberAdd/audits.ts b/src/plugins/events/guildMemberAdd/audits.ts index 7710fac..af6290a 100644 --- a/src/plugins/events/guildMemberAdd/audits.ts +++ b/src/plugins/events/guildMemberAdd/audits.ts @@ -48,12 +48,10 @@ export default { ]), ], }) - .then(async () => { - logger.debug( - `Audit log sent for event guildMemberAdd in guild ${member.guild.name} (${member.guild.id})` - ); + .then(() => { + logger.debug(`Audit log sent for event guildMemberAdd`); }) - .catch(async () => { + .catch(() => { throw new Error("Audit log failed to send"); }); }, diff --git a/src/plugins/events/guildMemberRemove/audits.ts b/src/plugins/events/guildMemberRemove/audits.ts index 72391fa..9f8b3e9 100644 --- a/src/plugins/events/guildMemberRemove/audits.ts +++ b/src/plugins/events/guildMemberRemove/audits.ts @@ -48,12 +48,10 @@ export default { ]), ], }) - .then(async () => { - logger.debug( - `Audit log sent for event guildMemberRemove in guild ${member.guild.name} (${member.guild.id})` - ); + .then(() => { + logger.debug(`Audit log sent for event guildMemberRemove.`); }) - .catch(async () => { + .catch(() => { throw new Error("Audit log failed to send"); }); },