🧑‍💻 Fixed more code smells

This commit is contained in:
Axel Olausson Holtenäs 2022-10-14 13:14:25 +02:00
parent 6d44db1c2c
commit 8b5dc9d51b
3 changed files with 13 additions and 17 deletions

View file

@ -31,15 +31,13 @@ export default {
await userData
.save()
.then(async () => {
.then(() => {
logger.silly(
`User ${userId} in guild ${guildId} has ${userData.credits} credits`
);
})
.catch(async (err) => {
logger.error(
`Error saving credits for user ${userId} in guild ${guildId} - ${err}`
);
.catch(() => {
throw new Error(`Error saving credits to database.`);
});
},
};

View file

@ -28,16 +28,13 @@ export default {
await userData
.save()
.then(async () => {
.then(() => {
logger.silly(
`Successfully saved user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})`
);
})
.catch(async (err) => {
logger.error(
`Error saving points for user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})`,
err
);
.catch(() => {
throw new Error("Error saving points to database.");
});
logger.silly(

View file

@ -1,4 +1,4 @@
import { EmbedBuilder, Message, TextChannel } from "discord.js";
import { ChannelType, EmbedBuilder, Message } from "discord.js";
import getEmbedConfig from "../../../helpers/getEmbedData";
import logger from "../../../middlewares/logger";
import guildSchema from "../../../models/guild";
@ -26,9 +26,10 @@ export default {
const channel = client.channels.cache.get(`${guildData.audits.channelId}`);
if (channel === null) return;
if (!channel) return;
if (channel.type !== ChannelType.GuildText) return;
(channel as TextChannel)
channel
.send({
embeds: [
new EmbedBuilder()
@ -50,13 +51,13 @@ export default {
}),
],
})
.then(async () => {
.then(() => {
logger.info(
`Audit log sent for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})`
);
})
.catch(async () => {
logger.error(
.catch(() => {
throw new Error(
`Audit log failed to send for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})`
);
});