!7 set flag DynModule. cmodule DiscordBot > DynPrintLogAndEnabled { transient JDA bot; start { logModuleOutput(); // TODO: log JDA output bot = discordBot(new ListenerAdapter { public void onMessageReceived(MessageReceivedEvent e) pcall { 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 = trim(e.getMessage().getContentRaw()); if (empty(content)) ret; GazelleEvalContext ctx = dm_gazelle_stdEvalContext(dm_gazelle_allRulesWithComment("discord")); GazelleTree tree = (ctx, content); L l = dm_gazelle_getChildren(tree); if (empty(l)) ret; final new Flag dontDelete; S answer = lines_rtrim(collect text(l)); e.getChannel().sendMessage(s).queue(msg -> { print("I sent msg: " + msg.getIdLong()); doLater(10.0, r { ret if dontDelete!; print("Deleting msg " + msg.getIdLong()); 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; } }