refactor: ♻️ Fixed more code smells

I have fixed more code smells
This commit is contained in:
Axel Olausson Holtenäs 2022-12-13 14:27:00 +01:00
parent c6d6547881
commit 0f8ea8ad2b
No known key found for this signature in database
GPG key ID: C4EF128A1BB3A5D2
6 changed files with 10 additions and 7 deletions

View file

@ -142,6 +142,5 @@ export default {
await interaction?.editReply({ await interaction?.editReply({
embeds: [interactionEmbed], embeds: [interactionEmbed],
}); });
return;
}, },
}; };

View file

@ -188,7 +188,6 @@ export default {
await interaction?.editReply({ await interaction?.editReply({
embeds: [interactionEmbed], embeds: [interactionEmbed],
}); });
return;
}); });
}); });
}, },

View file

@ -22,7 +22,10 @@ export default {
}, },
}); });
if (!channelCounter) return logger.debug("No counters found in channel."); if (!channelCounter) {
logger.debug("No counters found in channel.");
return false;
}
if ( if (
lastMessage?.author.id === author.id && lastMessage?.author.id === author.id &&
@ -32,7 +35,7 @@ export default {
`${author.username} sent the last message therefor not allowing again.` `${author.username} sent the last message therefor not allowing again.`
); );
await message.delete(); await message.delete();
return; return false;
} }
if (content !== channelCounter.triggerWord) { if (content !== channelCounter.triggerWord) {
@ -41,7 +44,7 @@ export default {
); );
await message.delete(); await message.delete();
return; return false;
} }
const updateGuildCounter = await prisma.guildCounter.update({ const updateGuildCounter = await prisma.guildCounter.update({

View file

@ -32,7 +32,7 @@ export default async (message: Message) => {
channel?.send(`${author} said **${channelCounter.triggerWord}**.`); channel?.send(`${author} said **${channelCounter.triggerWord}**.`);
logger?.silly(`${author} said ${channelCounter.triggerWord} in ${channel}`); logger?.silly(`${author} said ${channelCounter.triggerWord} in ${channel}`);
return logger?.silly( logger?.silly(
`User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${channelCounter.triggerWord}` `User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${channelCounter.triggerWord}`
); );
}; };

View file

@ -25,4 +25,5 @@ export const execute = async (oldMessage: Message, newMessage: Message) => {
if (author?.bot) return logger?.silly(`Message update event fired by bot`); if (author?.bot) return logger?.silly(`Message update event fired by bot`);
await counter(newMessage); await counter(newMessage);
return;
}; };

View file

@ -1,4 +1,4 @@
// Dependencies 1; // Dependencies
import { Message } from "discord.js"; import { Message } from "discord.js";
// Models // Models
import prisma from "../../../handlers/database"; import prisma from "../../../handlers/database";
@ -38,4 +38,5 @@ export default async (message: Message) => {
.catch((error) => { .catch((error) => {
logger.error(error); logger.error(error);
}); });
return;
}; };