!7 lib 1400185 import net.dv8tion.jda.core.*; import net.dv8tion.jda.core.entities.*; import net.dv8tion.jda.core.hooks.*; import net.dv8tion.jda.core.events.message.*; p-exp { logModuleOutput(); JDABuilder builder = new(AccountType.BOT); File tokenFile = javaxSecretDir("discord-bot-token"); builder.setToken(assertNempty("Need: " + tokenFile, trim(loadTextFile(tokenFile)))); builder.addEventListener(new ListenerAdapter { @Override public void onMessageReceived(MessageReceivedEvent e) { print("Channel type: " + e.getChannelType()); bool isPrivate = e.getChannelType() == ChannelType.PRIVATE; print("Msg from " + e.getAuthor().getName() + ": " + e.getMessage().getContentDisplay()); if (e.getAuthor().isBot()) ret with print(" Msg from bot, skipping"); S content = e.getMessage().getContentRaw(); if (nempty(content)) { print("Next-to-last char: " + intToHex(nextToLastChar(content)); print("Last char: " + intToHex(lastChar(content)); } new Matches m; S s = ""; if (isPrivate) s = content; else if (swic(content, "gazelle", m)) s = m.rest(); if (empty(s)) ret; /*if (!regexpContains("^:[a-z]", s)) s = dropLeadingPunctuation(s);*/ s = "Bah! " + trim(s); print("Sending: " + s); e.getChannel().sendMessage(s).queue(); } }); builder.buildAsync(); }