@@ -0,0 +1,3082 @@
+package com.tterrag.k9.commands;%0A%0Aimport java.io.ByteArrayInputStream;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.time.LocalDateTime;%0Aimport java.time.format.DateTimeFormatter;%0A%0Aimport com.google.gson.GsonBuilder;%0Aimport com.tterrag.k9.commands.api.Argument;%0Aimport com.tterrag.k9.commands.api.Command;%0Aimport com.tterrag.k9.commands.api.CommandBase;%0Aimport com.tterrag.k9.commands.api.CommandContext;%0Aimport com.tterrag.k9.commands.api.CommandPersisted;%0Aimport com.tterrag.k9.util.BakedMessage;%0A%0Aimport discord4j.core.object.util.Snowflake;%0Aimport reactor.core.publisher.Mono;%0A%0A@Command%0Apublic class CommandDump extends CommandBase %7B%0A    %0A    private static final Argument%3CString%3E COMMAND_NAME = new WordArgument(%22command%22, %22The command to dump data for%22, true);%0A    %0A    private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern(%22yyyy.MM.dd-HHmmss%22);%0A    %0A    public CommandDump() %7B%0A        super(%22dump%22, true);%0A    %7D%0A%0A    @Override%0A    public Mono%3C?%3E process(CommandContext ctx) %7B%0A        // Find the command by name%0A        final String cmd = ctx.getArg(COMMAND_NAME);%0A        return Mono.justOrEmpty(ctx.getK9().getCommands().findCommand(ctx, cmd))%0A                .switchIfEmpty(ctx.error(%22Invalid command: %22 + cmd))%0A                // Check if it's a command that has data%0A                .ofType(CommandPersisted.class)%0A                .map(c -%3E (CommandPersisted%3C?%3E) c)%0A                .switchIfEmpty(ctx.error(%22Command '%22 + cmd + %22' has no data%22))%0A                // Create a Gson for this command and serialize the data, if present%0A                .flatMap(c -%3E Mono.justOrEmpty(c.getData(ctx))%0A                        .flatMap(d -%3E Mono.just(new GsonBuilder().setPrettyPrinting())%0A                                .doOnNext(c::gatherParsers)%0A                                .map(GsonBuilder::create)%0A                                .map(g -%3E g.toJson(d))))%0A                .switchIfEmpty(ctx.error(%22No data found for command '%22 + cmd + %22' in this guild%22))%0A                // Create a message with the input attached as a file%0A                .map(s -%3E new BakedMessage()%0A                        .withFile(new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8)))%0A                        .withFileName(ctx.getArg(COMMAND_NAME) + %22-%22%0A                                + ctx.getGuildId().map(Snowflake::asString).orElse(%22DM%22) + %22-%22%0A                                + LocalDateTime.now().format(TIME_FORMAT) + %22.json%22))%0A                // DM to the command author%0A                .flatMap(m -%3E ctx.getMember()%0A                        .flatMap(u -%3E u.getPrivateChannel())%0A                        .flatMap(m::send)%0A                        // Delete the command if all succeeded%0A                        .flatMap(msg -%3E ctx.getMessage().delete().thenReturn(msg)))%0A                .switchIfEmpty(ctx.error(%22Could not create private channel%22));%0A    %7D%0A%0A    @Override%0A    public String getDescription(CommandContext ctx) %7B%0A        return %22Dump the data for this command in this guild to a file, which will be direct messaged to the user.%22;%0A    %7D%0A%7D%0A

Add !dump