Skip to content

omardiaadev/discord-html-transcript-jda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord-html-transcript-jda

Generate natively styled Discord chat logs with JDA
discord-html-transcript wrapper for Java Discord API

Maven Version discord-html-transcript License
Discord

Table of Contents

Features

  • 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 CompletableFuture for non-blocking performance.

Preview

Preview

Getting Started

Prerequisites

  • Java 17+
  • Your bot must enable the following intents:
    • Message Content

Installation

Maven

<dependency>
  <groupId>dev.omardiaa</groupId>
  <artifactId>discord-html-transcript-jda</artifactId>
  <version>0.1.0-beta.2</version>
</dependency>

Gradle

implementation("dev.omardiaa:discord-html-transcript-jda:0.1.0-beta.2")

Usage

Example: Slash Command

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;
            });
    }
  }
}

Contributing

If you found discord-html-transcript-jda useful, please consider giving it a 🌟!

Need help? Ask the Community!

Made With ❤️ By Omar Diaa

Fiverr Ko-fi