Class ChannelUtils

java.lang.Object
com.dianxin.tori.api.utils.jda.ChannelUtils

public final class ChannelUtils extends Object
A utility class providing convenient methods to retrieve JDA Channel objects from the internal cache.

Note: This class must be initialized via initialize(JDA) before use.

  • Method Details

    • initialize

      public static void initialize(@NotNull @NotNull JDA jda)
      Initializes the ChannelUtils with a JDA instance. This must be called before attempting to retrieve any channels.
      Parameters:
      jda - The global JDA instance.
    • getChannelById

      public static Channel getChannelById(String id)
      Retrieves a generic Channel by its snowflake ID from the JDA cache.
      Parameters:
      id - The snowflake ID of the channel.
      Returns:
      The Channel, or null if not found in cache.
    • getTextChannelById

      public static TextChannel getTextChannelById(String id)
      Retrieves a specific TextChannel by its snowflake ID from the JDA cache.
      Parameters:
      id - The snowflake ID of the text channel.
      Returns:
      The TextChannel, or null if not found in cache or if the ID belongs to a different channel type.
    • getVoiceChannelById

      public static VoiceChannel getVoiceChannelById(String id)
      Retrieves a specific VoiceChannel by its snowflake ID from the JDA cache.
      Parameters:
      id - The snowflake ID of the voice channel.
      Returns:
      The VoiceChannel, or null if not found in cache or if the ID belongs to a different channel type.