Skip to content

Commit

Permalink
fix: bot only replies private messages (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
manelp committed Mar 22, 2024
2 parents 8448f3c + cfc3a2f commit 7d8af3f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.agilogy.timetracking.app

import com.agilogy.timetracking.domain.TimeTrackingApp
import kotlinx.coroutines.runBlocking
import net.dv8tion.jda.api.entities.channel.ChannelType
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.events.message.MessageReceivedEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter
Expand Down Expand Up @@ -30,7 +31,7 @@ class EventsListener(private val timeTrackingApp: TimeTrackingApp) : ListenerAda
try {
logger.info("Message received: ${event.message.contentRaw} by ${event.author}")

if (!event.author.isBot) {
if (!event.author.isBot && event.channelType == ChannelType.PRIVATE) {
val response = if (event.message.contentRaw.trim().lowercase() == "projectes") {
timeTrackingApp.listProjects().joinToString(", ") { it.name }
} else {
Expand Down

0 comments on commit 7d8af3f

Please sign in to comment.