Package com.dianxin.tori.api.utils.jda
Class ChannelUtils
java.lang.Object
com.dianxin.tori.api.utils.jda.ChannelUtils
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 TypeMethodDescriptionstatic net.dv8tion.jda.api.entities.channel.ChannelgetChannelById(String id) Retrieves a genericChannelby its snowflake ID from the JDA cache.static net.dv8tion.jda.api.entities.channel.concrete.TextChannelRetrieves a specificTextChannelby its snowflake ID from the JDA cache.static net.dv8tion.jda.api.entities.channel.concrete.VoiceChannelRetrieves a specificVoiceChannelby its snowflake ID from the JDA cache.static voidinitialize(@NotNull net.dv8tion.jda.api.JDA jda) Initializes the ChannelUtils with a JDA instance.
-
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
Retrieves a genericChannelby its snowflake ID from the JDA cache.- Parameters:
id- The snowflake ID of the channel.- Returns:
- The
Channel, ornullif not found in cache.
-
getTextChannelById
public static net.dv8tion.jda.api.entities.channel.concrete.TextChannel getTextChannelById(String id) Retrieves a specificTextChannelby its snowflake ID from the JDA cache.- Parameters:
id- The snowflake ID of the text channel.- Returns:
- The
TextChannel, ornullif 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 specificVoiceChannelby its snowflake ID from the JDA cache.- Parameters:
id- The snowflake ID of the voice channel.- Returns:
- The
VoiceChannel, ornullif not found in cache or if the ID belongs to a different channel type.
-