🧑💻 Fixed some more code smells
This commit is contained in:
parent
586caab107
commit
4c348a6e73
10 changed files with 23 additions and 19 deletions
|
@ -51,11 +51,8 @@ export const execute = async (client: Client, role: IShopRole) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(async (err) => {
|
.catch(() => {
|
||||||
throw new Error(
|
throw new Error(`Failed removing role from user.`);
|
||||||
`Error removing role ${roleId} from user ${userId}.`,
|
|
||||||
err
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
throw new Error("User does not have enough credits.");
|
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();
|
role.lastPayed = new Date();
|
||||||
await role
|
await role
|
||||||
.save()
|
.save()
|
||||||
.then(async () => {
|
.then(() => {
|
||||||
logger.silly(`Shop role ${roleId} has been updated.`);
|
logger.silly(`Shop role ${roleId} has been updated.`);
|
||||||
})
|
})
|
||||||
.catch(async (err) => {
|
.catch(() => {
|
||||||
throw new Error(`Error updating shop role ${roleId}.`, err);
|
throw new Error("Failed updating shop role.");
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug(`Shop role ${roleId} has been paid.`);
|
logger.debug(`Shop role ${roleId} has been paid.`);
|
||||||
})
|
})
|
||||||
.catch(async (err) => {
|
.catch(() => {
|
||||||
throw new Error(`Error updating user ${userId}.`, err);
|
throw new Error("Failed updating user.");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ export const execute = async () => {
|
||||||
timeoutId,
|
timeoutId,
|
||||||
cooldown,
|
cooldown,
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(() => {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Timeout document ${timeoutId} has been deleted from user ${userId}.`
|
`Timeout document ${timeoutId} has been deleted from user ${userId}.`
|
||||||
);
|
);
|
||||||
|
|
|
@ -78,9 +78,10 @@ export default {
|
||||||
text: footerText,
|
text: footerText,
|
||||||
});
|
});
|
||||||
|
|
||||||
return interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [embedSuccess],
|
embeds: [embedSuccess],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,9 +80,10 @@ export default {
|
||||||
text: footerText,
|
text: footerText,
|
||||||
});
|
});
|
||||||
|
|
||||||
return interaction?.editReply({
|
await interaction?.editReply({
|
||||||
embeds: [interactionEmbed],
|
embeds: [interactionEmbed],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -126,9 +126,10 @@ export default {
|
||||||
text: footerText,
|
text: footerText,
|
||||||
});
|
});
|
||||||
|
|
||||||
return interaction?.editReply({
|
await interaction?.editReply({
|
||||||
embeds: [interactionEmbed],
|
embeds: [interactionEmbed],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,9 +86,10 @@ export default {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,9 +98,10 @@ export default {
|
||||||
text: footerText,
|
text: footerText,
|
||||||
});
|
});
|
||||||
|
|
||||||
return interaction?.editReply({
|
await interaction?.editReply({
|
||||||
embeds: [interactionEmbed],
|
embeds: [interactionEmbed],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,9 +79,10 @@ export default {
|
||||||
text: footerText,
|
text: footerText,
|
||||||
});
|
});
|
||||||
|
|
||||||
return interaction?.editReply({
|
await interaction?.editReply({
|
||||||
embeds: [interactionEmbed],
|
embeds: [interactionEmbed],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -171,9 +171,10 @@ export default {
|
||||||
text: footerText,
|
text: footerText,
|
||||||
});
|
});
|
||||||
|
|
||||||
return interaction?.editReply({
|
await interaction?.editReply({
|
||||||
embeds: [interactionEmbed],
|
embeds: [interactionEmbed],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default {
|
||||||
if (!userObj) throw new Error("User is undefined");
|
if (!userObj) throw new Error("User is undefined");
|
||||||
|
|
||||||
// Pre-checks
|
// Pre-checks
|
||||||
await noSelfReputation(optionTarget, user);
|
noSelfReputation(optionTarget, user);
|
||||||
|
|
||||||
// Check if user is on cooldown otherwise create one
|
// Check if user is on cooldown otherwise create one
|
||||||
await cooldown.command(interaction, process.env.REPUTATION_TIMEOUT);
|
await cooldown.command(interaction, process.env.REPUTATION_TIMEOUT);
|
||||||
|
|
Loading…
Add table
Reference in a new issue