With JDA you are able to create a Bot for Discord.
Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.
discord.com
Find out more about Discord-Bots in the Discord-Developer-Portal
Build games, experiences, and integrations for millions of users on Discord.
discord.com
Setup:
You need to add the following jars to your Project.
#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-1.7.25
#AdditionalJar: slf4j-jdk14-1.7.25
#AdditionalJar: commons-collections4-4.1
#AdditionalJar: okio-2.6.0
#AdditionalJar: kotlin-stdlib-1.3.41
#AdditionalJar: kotlin-stdlib-jdk8-1.3.41
#AdditionalJar: nv-websocket-client-2.14
#AdditionalJar: trove4j-3.0.3
They are all inside the follwing zip which can be downloaded from my Dropbox as the file-size is more than 500kb.
Download here:
You´ll need to download the newest JDA.jar here:
Download JDA-5.0.0-beta.2.jar and put it in your additional libs folder. Also remember to reference it using
#additionaljar:JDA-5.0.0-beta.2
The following code is needed in your appstart
Dim b As JDABuilder
b.Initialize2(token) ' String token from Developersite
b.setAutoReconnect(True).setEnableShutdownHook(True)
jda.Initialize("JDA",b.build)
Dim sh As DefaultShardManagerBuilder
sh.Initialize("ShardManager")
sh.setToken(token)
sh.build
jda.awaitReady
onReady is called when the JDA has finished initialisation and you can now use Api methods.
Sub JDA_onReady(event As Object)
Log($"JDA_onReady(${event})"$)
End Sub
onMessageReceived is the main-entry point for you as the Developer.
Every Message the Bot receives raises this Event. You even get Events for Message you send.
Sub JDA_onMessageReceived(event As Object)
Log($"JDA_onMessageReceived(${event})"$)
Dim ev As MessageReceivedEvent = event
End Sub
onGuildMemberJoin is a Event which is raised the First Time a new User Logged in into your Discord Server.
Or better. A user Logged in into one of the Guilds your Bot has Access to.
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
Please create a new Thread for any Question or Issues you have with this Library in the
B4J Questions Forum. Prefix your Thread with [JDA] please.
You won´t get Support in this Thread.