Hi, as the title says, I couldn't find a way to use the new JDA (Discord Bot) library.
Following the example:
Compiling the following code works, the UI app opens, but freezes, seems that it's waiting for something, maybe the missing "jda.awaitReady" ?
Thank you for your help!
Following the example:
- - I downoaded all the dependencies from https://mvnrepository.com/
- - The project compiles with all the latest version of each dependencies, except for Okio, which requires version 2.6.0 (otherwise it won't compile)
- - I've successfully created a Discord Bot on the dev. console. I got my Bot Token
- - The jda.AwaitReady doesn't seem to be part of the library now.
Compiling the following code works, the UI app opens, but freezes, seems that it's waiting for something, maybe the missing "jda.awaitReady" ?
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar:JDA-5.0.0-beta.2
'#AdditionalJar: mysql-connector-java-5.1.34-bin
#AdditionalJar: jackson-databind-2.10.1
#AdditionalJar: jackson-core-2.10.1
#AdditionalJar: jackson-annotations-2.11.0
#AdditionalJar: okhttp-3.13.0
#AdditionalJar: slf4j-api-2.0.17
#AdditionalJar: slf4j-jdk14-2.0.17
#AdditionalJar: commons-collections4-4.5.0
#AdditionalJar: okio-2.6.0
#AdditionalJar: kotlin-stdlib-2.1.20
#AdditionalJar: kotlin-stdlib-jdk8-2.1.20
#AdditionalJar: nv-websocket-client-2.14
#AdditionalJar: trove4j-3.0.3
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Dim jda As JDA
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
Dim Token As String = "mytokenFromDiscordDevelopper.aDSLKjsadkljfkasf.blahblah"
Dim b As JDABuilder
b.Initialize("JDA", Token) ' String token from Developersite
b.setAutoReconnect(True).setEnableShutdownHook(True)
jda.Initialize("JDA",b.build)
Dim sh As DefaultShardManagerBuilder
sh.Initialize("ShardManager", Token)
sh.setToken(Token)
sh.build
'jda.awaitready
End Sub
Sub JDA_onStatusChange(event As StatusChangeEvent)
Log($"JDA_onStatusChange(${event})"$)
End Sub
Sub JDA_onMessageReceived(event As MessageReceivedEvent)
Log($"JDA_onMessageReceived(${event})"$)
End Sub
Sub JDA_onGuildMemberJoin(event As GuildMemberJoinEvent)
Log($"JDA_onGuildMemberJoin(${event})"$)
'Dim ev As GuildMemberJoinEvent = event
Log($"GuildMemberJoin.Member ${event.Member}"$)
Log($"GuildMemberJoin.User ${event.User}"$)
End Sub
Thank you for your help!
Last edited: