Uses 10105K of libraries. Click here for Pure Java version (3075L/18K).
ifndef DifferentJDA //lib 1400315 // JDA 4.0 with opus lib 1400445 // JDA 4.2 with opus //static LS _stickyLibs_discordBot = ll(#1400315); // can cause loader constraint violations endifndef import net.dv8tion.jda.api.*; import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.hooks.*; import net.dv8tion.jda.api.events.message.*; import net.dv8tion.jda.api.events.message.react.*; import static net.dv8tion.jda.api.requests.GatewayIntent.*; static JDA discordBot40(VF1<MessageReceivedEvent> onMessage, O... _) { ret discordBot40(new ListenerAdapter { @Override public void onMessageReceived(MessageReceivedEvent e) { if (e.getAuthor().isBot()) ret with print(" Msg from bot, skipping"); pcallF(onMessage, e); } }, _); } static JDA discordBot40(ListenerAdapter listener, O... _) ctex { S token = stringPar token(_); if (empty(token)) { File tokenFile = javaxSecretDir("discord-bot-token"); token = assertNempty("Need: " + tokenFile, trim(loadTextFile(tokenFile))); } print("Making JDABuilder"); JDABuilder builder = JDABuilder.create(token, GUILD_VOICE_STATES, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS, DIRECT_MESSAGES); print("Have JDABuilder"); if (boolPar membersIntent(_)) builder.enableIntents(GUILD_MEMBERS); builder.addEventListeners(listener); print("Building JDA with token " + shorten(10, token)); JDA jda = builder.build(); print("Got JDA: " + jda); //jda.awaitSatus(JDA.Status.CONNECTED); jda.awaitReady(); print("Started Discord bot (token: " + shorten(token, 7) + ")"); ret jda; }
Began life as a copy of #1021617
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026291 |
Snippet name: | discordBot40 - using JDA 4.0 |
Eternal ID of this version: | #1026291/10 |
Text MD5: | 9cd9dd646afb56f92edcefe31adead94 |
Transpilation MD5: | 89991ab1c005ea321e3ac915ee3e8d50 |
Author: | stefan |
Category: | javax / discord |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-01-26 05:21:35 |
Source code size: | 1671 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 296 / 404 |
Version history: | 9 change(s) |
Referenced in: | [show references] |