Transpiled version (2839L) is out of date.
ifndef DifferentJDA lib 1400215 // discord without opus/JNA //static LS _stickyLibs_discordBot = ll(#1400215); // can cause loader constraint violations endifndef import net.dv8tion.jda.core.*; import net.dv8tion.jda.core.entities.*; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.hooks.*; import net.dv8tion.jda.core.events.*; import net.dv8tion.jda.core.events.message.*; import net.dv8tion.jda.core.events.message.react.*; static JDA discordBot(final VF1<MessageReceivedEvent> onMessage) { ret discordBot(new ListenerAdapter { @Override public void onMessageReceived(MessageReceivedEvent e) { if (e.getAuthor().isBot()) ret with print(" Msg from bot, skipping"); pcallF(onMessage, e); } }); } static JDA discordBot(ListenerAdapter listener, O... _) ctex { print("Making JDABuilder"); JDABuilder builder = new(AccountType.BOT); print("Have JDABuilder"); S token = stringPar token(_); if (empty(token)) { File tokenFile = javaxSecretDir("discord-bot-token"); token = assertNempty("Need: " + tokenFile, trim(loadTextFile(tokenFile))); } builder.setToken(token); builder.addEventListener(listener); print("Building JDA with token " + shorten(10, token)); JDA jda = builder.build(); print("Got JDA: " + jda); jda.addEventListener(new ListenerAdapter { public void onStatusChange(StatusChangeEvent event) { print("JDA status: " + event.getNewStatus()); } }); //jda.awaitSatus(JDA.Status.CONNECTED); jda.awaitReady(); print("Started Discord bot (token: " + shorten(token, 7) + ")"); ret jda; }
Began life as a copy of #1021602
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021617 |
Snippet name: | discordBot - now waits for connection |
Eternal ID of this version: | #1021617/28 |
Text MD5: | bafda1897fe00eceebfdec58256a80f1 |
Author: | stefan |
Category: | javax / discord |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-07 00:48:37 |
Source code size: | 1651 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 358 / 536 |
Version history: | 27 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1026291 - discordBot40 - using JDA 4.0 #1030355 - discordBot [backup] |