mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-12-06 03:07:18 +00:00
- 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
20 lines
743 B
Kotlin
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}")
|
|
}
|
|
}
|
|
}
|