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 Summary

    Modifier and Type
    Method
    Description
    static net.dv8tion.jda.api.entities.channel.Channel
    Retrieves a generic Channel by its snowflake ID from the JDA cache.
    static net.dv8tion.jda.api.entities.channel.concrete.TextChannel
    Retrieves a specific TextChannel by its snowflake ID from the JDA cache.
    static net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel
    Retrieves a specific VoiceChannel by its snowflake ID from the JDA cache.
    static void
    initialize(@NotNull net.dv8tion.jda.api.JDA jda)
    Initializes the ChannelUtils with a JDA instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • initialize

      public static void initialize(@NotNull @NotNull net.dv8tion.jda.api.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 net.dv8tion.jda.api.entities.channel.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 net.dv8tion.jda.api.entities.channel.concrete.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 net.dv8tion.jda.api.entities.channel.concrete.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.