🧑‍💻 Fixed some more code smells

This commit is contained in:
Axel Olausson Holtenäs 2022-10-16 15:25:05 +02:00
parent 586caab107
commit 4c348a6e73
10 changed files with 23 additions and 19 deletions

View file

@ -51,11 +51,8 @@ export const execute = async (client: Client, role: IShopRole) => {
);
});
})
.catch(async (err) => {
throw new Error(
`Error removing role ${roleId} from user ${userId}.`,
err
);
.catch(() => {
throw new Error(`Failed removing role from user.`);
});
throw new Error("User does not have enough credits.");
@ -70,16 +67,16 @@ export const execute = async (client: Client, role: IShopRole) => {
role.lastPayed = new Date();
await role
.save()
.then(async () => {
.then(() => {
logger.silly(`Shop role ${roleId} has been updated.`);
})
.catch(async (err) => {
throw new Error(`Error updating shop role ${roleId}.`, err);
.catch(() => {
throw new Error("Failed updating shop role.");
});
logger.debug(`Shop role ${roleId} has been paid.`);
})
.catch(async (err) => {
throw new Error(`Error updating user ${userId}.`, err);
.catch(() => {
throw new Error("Failed updating user.");
});
};

View file

@ -24,7 +24,7 @@ export const execute = async () => {
timeoutId,
cooldown,
})
.then(async () => {
.then(() => {
logger.debug(
`Timeout document ${timeoutId} has been deleted from user ${userId}.`
);

View file

@ -78,9 +78,10 @@ export default {
text: footerText,
});
return interaction.editReply({
await interaction.editReply({
embeds: [embedSuccess],
});
return;
});
},
};

View file

@ -80,9 +80,10 @@ export default {
text: footerText,
});
return interaction?.editReply({
await interaction?.editReply({
embeds: [interactionEmbed],
});
return;
});
},
};

View file

@ -126,9 +126,10 @@ export default {
text: footerText,
});
return interaction?.editReply({
await interaction?.editReply({
embeds: [interactionEmbed],
});
return;
});
},
};

View file

@ -86,9 +86,10 @@ export default {
},
]);
return interaction.editReply({
await interaction.editReply({
embeds: [embed],
});
return;
});
},
};

View file

@ -98,9 +98,10 @@ export default {
text: footerText,
});
return interaction?.editReply({
await interaction?.editReply({
embeds: [interactionEmbed],
});
return;
});
},
};

View file

@ -79,9 +79,10 @@ export default {
text: footerText,
});
return interaction?.editReply({
await interaction?.editReply({
embeds: [interactionEmbed],
});
return;
});
},
};

View file

@ -171,9 +171,10 @@ export default {
text: footerText,
});
return interaction?.editReply({
await interaction?.editReply({
embeds: [interactionEmbed],
});
return;
});
},
};

View file

@ -49,7 +49,7 @@ export default {
if (!userObj) throw new Error("User is undefined");
// Pre-checks
await noSelfReputation(optionTarget, user);
noSelfReputation(optionTarget, user);
// Check if user is on cooldown otherwise create one
await cooldown.command(interaction, process.env.REPUTATION_TIMEOUT);