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

Unlink user on leave #29

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion common/src/main/kotlin/dev/erdragh/astralbot/Bot.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.erdragh.astralbot

import dev.erdragh.astralbot.commands.discord.CommandHandlingListener
import dev.erdragh.astralbot.commands.discord.UserEventListener
import dev.erdragh.astralbot.config.AstralBotConfig
import dev.erdragh.astralbot.handlers.FAQHandler
import dev.erdragh.astralbot.handlers.MinecraftHandler
Expand Down Expand Up @@ -127,7 +128,11 @@ fun startAstralbot(server: MinecraftServer) {
GatewayIntent.MESSAGE_CONTENT,
GatewayIntent.GUILD_MESSAGES,
GatewayIntent.GUILD_MEMBERS
).addEventListeners(CommandHandlingListener, minecraftHandler).build()
).addEventListeners(
CommandHandlingListener,
UserEventListener,
minecraftHandler
).build()

setupJob = GlobalScope.async {
launch {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.erdragh.astralbot.commands.discord

import dev.erdragh.astralbot.handlers.WhitelistHandler
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter

object UserEventListener : ListenerAdapter() {
override fun onGuildMemberRemove(event: GuildMemberRemoveEvent) {
WhitelistHandler.unWhitelist(event.user)
}
}