!7 cmodule DiscordBot > DynPrintLogAndEnabled { transient JDA bot; start { logModuleOutput(); // TODO: log JDA output bot = discordBot(new ListenerAdapter { public void onMessageReceived(MessageReceivedEvent e) { ret if !enabled || !licensed(); ret if e.getAuthor().isBot(); print("Channel type: " + e.getChannelType()); bool isPrivate = e.getChannelType() == ChannelType.PRIVATE; print("Msg from " + e.getAuthor().getName() + ": " + e.getMessage().getContentDisplay()); S content = e.getMessage().getContentRaw(); new Matches m; S s = ""; if (isPrivate) s = content; else if (swic(content, "gazelle", m)) s = m.rest(); if (empty(s)) ret; s = "Bah! " + trim(s); print("Sending: " + s); fbool delete = ewic(content, "delete"); e.getChannel().sendMessage(s).queue(msg -> { print("I sent msg: " + msg.getIdLong()); if (delete) doLater(5.0, r { msg.delete().queue(); }); }); } public void onMessageReactionAdd(MessageReactionAddEvent e) { ret if !enabled || !licensed(); MessageReaction r = e.getReaction(); bool bot = e.getUser().isBot(); print("User " + e.getUser() + (bot ? " (bot)" : "") + " reacted to message " + r.getMessageIdLong() + " with " + r.getReactionEmote()); if (bot) ret; e.getChannel().sendMessage("You just " + r.getReactionEmote().getName() + " ed").queue(); } }); print("Started bot"); } void cleanMeUp { if (bot != null) pcall { print("Shutting down bot"); bot.shutdown(); print("Bot shut down"); } bot = null; } }