Generate natively styled Discord chat logs with JDA
discord-html-transcript wrapper for Java Discord API
Table of Contents
- JDA Integration: Retrieve messages easily with your JDA client instance.
- Beautiful UI: Modern HTML/CSS that has the look and feel of the Discord desktop client.
- Asynchronous: Built with
CompletableFuturefor non-blocking performance.
- Java 17+
- Your bot must enable the following intents:
- Message Content
<dependency>
<groupId>dev.omardiaa</groupId>
<artifactId>discord-html-transcript-jda</artifactId>
<version>0.1.0-beta.2</version>
</dependency>implementation("dev.omardiaa:discord-html-transcript-jda:0.1.0-beta.2")import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import dev.omardiaa.transcript.jda.service.TranscriberClient;
import dev.omardiaa.transcript.jda.exception.TranscriberPermissionException;
public class SlashCommandListener extends ListenerAdapter {
private final TranscriberClient client;
public SlashCommandListener(JDA jda) {
this.client = new TranscriberClient(jda);
}
@Override
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
if (event.getName().equals("transcript")) {
// acknowledge the interaction before Discord expires it
event.deferReply().queue();
client.transcribe(event.getChannel())
.thenAccept(transcript -> {
// upload and send the transcript
event.getHook().sendFiles(transcript.toFileUpload()).queue();
})
.exceptionally(throwable -> {
if (throwable.getCause() instanceof TranscriberPermissionException ex) {
// handle permission exception
event.getHook()
.sendMessageFormat(
"Failed to generate transcript due to missing '%s' permission.",
ex.getPermission().getName())
.queue();
} else {
// handle other exceptions
event.getHook().sendMessage("Failed to generate transcript due to unknown exception.").queue();
}
return null;
});
}
}
}If you found discord-html-transcript-jda useful, please consider giving it a 🌟!
Need help? Ask the Community!