Files
2006Scape/2006Scape Server/plugins/plugin/integration/discord/WelcomeMessage.kt
T
Dark98 fbc3595da1 Discord Bot Rewrite, Upgrades & Plugin Migration
- Replace deprecated Core Javacord implementation with a modern JDA 5.x Kotlin plugin
- Introduce event-driven architecture via ServerConfigEvent, ServerStartupEvent, ServerShutdownEvent, and CommandEvent
- Implemented global event posting functionality in Player class.
- Refactored PluginService to handle potential ClassNotFoundException more gracefully.
- Improved CustomPrintStream to better identify the caller context in log messages.
- Refactor server configuration into modular groups ("core" and "discord") with backward compatibility for legacy flat keys
2026-11-12 23:56:07 +00:00

20 lines
743 B
Kotlin

package plugin.integration.discord
import com.rs2.Constants
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter
class WelcomeMessage : ListenerAdapter() {
override fun onGuildMemberJoin(event: GuildMemberJoinEvent) {
try {
if (DiscordConfig.welcomeChannelId.isNotEmpty()) {
val channel = event.guild.getTextChannelById(DiscordConfig.welcomeChannelId)
channel?.sendMessage("Hello ${event.user.asMention}, and welcome to the ${Constants.SERVER_NAME} Discord server!")?.queue()
}
} catch (e: Exception) {
System.err.println("Failed to send welcome message: ${e.message}")
}
}
}