🧑‍💻 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 await userData
.save() .save()
.then(async () => { .then(() => {
logger.silly( logger.silly(
`User ${userId} in guild ${guildId} has ${userData.credits} credits` `User ${userId} in guild ${guildId} has ${userData.credits} credits`
); );
}) })
.catch(async (err) => { .catch(() => {
logger.error( throw new Error(`Error saving credits to database.`);
`Error saving credits for user ${userId} in guild ${guildId} - ${err}`
);
}); });
}, },
}; };

View file

@ -28,16 +28,13 @@ export default {
await userData await userData
.save() .save()
.then(async () => { .then(() => {
logger.silly( logger.silly(
`Successfully saved user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` `Successfully saved user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})`
); );
}) })
.catch(async (err) => { .catch(() => {
logger.error( throw new Error("Error saving points to database.");
`Error saving points for user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})`,
err
);
}); });
logger.silly( 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 getEmbedConfig from "../../../helpers/getEmbedData";
import logger from "../../../middlewares/logger"; import logger from "../../../middlewares/logger";
import guildSchema from "../../../models/guild"; import guildSchema from "../../../models/guild";
@ -26,9 +26,10 @@ export default {
const channel = client.channels.cache.get(`${guildData.audits.channelId}`); 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({ .send({
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()
@ -50,13 +51,13 @@ export default {
}), }),
], ],
}) })
.then(async () => { .then(() => {
logger.info( logger.info(
`Audit log sent for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})` `Audit log sent for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})`
); );
}) })
.catch(async () => { .catch(() => {
logger.error( throw new Error(
`Audit log failed to send for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})` `Audit log failed to send for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})`
); );
}); });