Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically remove reactions to help posts. #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/kotlin/com/learnspigot/bot/help/ThreadListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.learnspigot.bot.Server
import com.learnspigot.bot.util.embed
import net.dv8tion.jda.api.entities.channel.ChannelType
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter

class ThreadListener : ListenerAdapter() {
Expand All @@ -26,4 +27,17 @@ class ThreadListener : ListenerAdapter() {
.build()
).queue()
}

override fun onMessageReactionAdd(event: MessageReactionAddEvent) {
if (event.channelType != ChannelType.GUILD_PUBLIC_THREAD) return

val channel = event.channel.asThreadChannel()
if (channel.parentChannel.id != Server.helpChannel.id) return
if (channel.id != event.messageId) return

event.retrieveUser().queue { user ->
if (user.isBot || user.isSystem) return@queue
event.reaction.removeReaction(user).queue()
}
}
}