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 ChannelgetChannelById(String id) Retrieves a genericChannelby its snowflake ID from the JDA cache.static TextChannelRetrieves a specificTextChannelby its snowflake ID from the JDA cache.static VoiceChannelRetrieves a specificVoiceChannelby its snowflake ID from the JDA cache.static voidinitialize(@NotNull JDA jda) Initializes the ChannelUtils with a JDA instance.
-
Method Details
-
initialize
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
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
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.
-