Class JDAContext

java.lang.Object
io.github.kaktushose.jdac.internal.JDAContext

public final class JDAContext extends Object
Wrapper class for JDA and ShardManager. Use performTask(Consumer, boolean) when you need to do work with an JDA object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    JDAContext(net.dv8tion.jda.api.JDA jda)
    Constructs a new JDAContext.
    JDAContext(net.dv8tion.jda.api.sharding.ShardManager shardManager)
    Constructs a new JDAContext.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<net.dv8tion.jda.api.entities.emoji.ApplicationEmoji>
     
    net.dv8tion.jda.api.utils.cache.SnowflakeCacheView<net.dv8tion.jda.api.entities.Guild>
    SnowflakeCacheView of all cached Guilds.
    void
    performTask(Consumer<net.dv8tion.jda.api.JDA> consumer, boolean onlyFirstShard)
    Performs an operation on either the JDA object or on all shards.
    void
    Shutdown the underlying JDA or ShardManager instance

    Methods inherited from class Object

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

    • log

      public static final org.slf4j.Logger log
  • Constructor Details

    • JDAContext

      public JDAContext(net.dv8tion.jda.api.sharding.ShardManager shardManager)
      Constructs a new JDAContext.
      Parameters:
      shardManager - the ShardManager object
    • JDAContext

      public JDAContext(net.dv8tion.jda.api.JDA jda)
      Constructs a new JDAContext.
      Parameters:
      jda - the JDA object
  • Method Details

    • performTask

      public void performTask(Consumer<net.dv8tion.jda.api.JDA> consumer, boolean onlyFirstShard)
      Performs an operation on either the JDA object or on all shards.
      Parameters:
      consumer - the operation to perform
      onlyFirstShard - whether this task should only be executed on the first shard if a ShardManager is used
    • getGuildCache

      public net.dv8tion.jda.api.utils.cache.SnowflakeCacheView<net.dv8tion.jda.api.entities.Guild> getGuildCache()
      SnowflakeCacheView of all cached Guilds.
      Returns:
      the SnowflakeCacheView
    • applicationEmojis

      public List<net.dv8tion.jda.api.entities.emoji.ApplicationEmoji> applicationEmojis()
    • shutdown

      public void shutdown()
      Shutdown the underlying JDA or ShardManager instance