diff --git a/src/events/messageCreate/modules/counters/index.ts b/src/events/messageCreate/modules/counters/index.ts index 2e82388..6f852c7 100644 --- a/src/events/messageCreate/modules/counters/index.ts +++ b/src/events/messageCreate/modules/counters/index.ts @@ -14,14 +14,6 @@ export default { const messages = await message.channel.messages.fetch({ limit: 2 }); const lastMessage = messages.last(); - if (lastMessage?.author.id === author.id) { - logger.verbose( - `${author.username} sent the last message therefor not allowing again.` - ); - await message.delete(); - return; - } - const { id: guildId } = guild; const { id: channelId } = channel; @@ -30,20 +22,30 @@ export default { channelId, }); - if (!counter) { + if (counter === null) { logger.verbose( `No counter found for guild ${guildId} and channel ${channelId}` ); return; } + if ( + lastMessage?.author.id === author.id && + channel.id === counter.channelId + ) { + logger.verbose( + `${author.username} sent the last message therefor not allowing again.` + ); + await message.delete(); + return; + } + if (content !== counter.word) { logger.verbose( `Counter word ${counter.word} does not match message ${content}` ); await message.delete(); - return; }