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 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; }