diff --git a/src/bot.js b/src/bot.js index aaece1d..ae822c6 100644 --- a/src/bot.js +++ b/src/bot.js @@ -8,7 +8,7 @@ import {utils} from "./helpers/utils.js"; env.config({path: './.env'}); -export const token = process.env.FLUXER_BOT_TOKEN; +const token = process.env.FLUXER_BOT_TOKEN; if (!token) { console.error("Missing FLUXER_BOT_TOKEN environment variable."); @@ -30,11 +30,10 @@ client.on(Events.MessageCreate, async (message) => { **/ export const handleMessageCreate = async function(message) { try { + // Ignore bots + if (message.author.bot) return; // Parse command and arguments const content = message.content.trim(); - // Ignore bots and messages without content - if (message.author.bot || content.length === 0) return; - // If message doesn't start with the bot prefix, it could still be a message with a proxy tag. If it's not, return. if (!content.startsWith(messageHelper.prefix)) { return await webhookHelper.sendMessageAsMember(client, message); diff --git a/tests/bot.test.js b/tests/bot.test.js index 748550b..4723a16 100644 --- a/tests/bot.test.js +++ b/tests/bot.test.js @@ -87,19 +87,6 @@ describe('bot', () => { expect(res).toBeUndefined(); }) - test('on message creation, if message is empty, return', async () => { - // Arrange - const message = { - content: " ", - author: { - bot: false - } - } - // Act - const res = await handleMessageCreate(message); - expect(res).toBeUndefined(); - }) - test("if message doesn't start with bot prefix, call sendMessageAsMember", async () => { // Arrange webhookHelper.sendMessageAsMember.mockResolvedValue();