Java Code Examples for net.dv8tion.jda.api.events.ReadyEvent#getJDA()

The following examples show how to use net.dv8tion.jda.api.events.ReadyEvent#getJDA() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReadyShutdownListener.java    From SkyBot with GNU Affero General Public License v3.0 6 votes vote down vote up
private void onReady(ReadyEvent event) {
    final JDA jda = event.getJDA();
    logger.info("Logged in as {} (Shard {})", jda.getSelfUser().getAsTag(), jda.getShardInfo().getShardId());

    //Start the timers if they have not been started yet
    if (!arePoolsRunning.get()) {
        logger.info("Starting spam-cache-cleaner!");
        systemPool.scheduleAtFixedRate(spamFilter::clearMessages, 20, 13, TimeUnit.SECONDS);

        if (!variables.useApi()) {
            this.startSQLiteTimers();
        }

        arePoolsRunning.set(true);

        // Load the patrons here so that they are loaded once
        GuildUtils.loadAllPatrons(variables.getDatabaseAdapter());
    }
}
 
Example 2
Source File: Shard.java    From MantaroBot with GNU General Public License v3.0 5 votes vote down vote up
public Shard(int id) {
    this.id = id;
    this.listener = new ListenerAdapter() {
        @Override
        public synchronized void onReady(@Nonnull ReadyEvent event) {
            jda = event.getJDA();
            if (statusChange != null) {
                statusChange.cancel(true);
            }

            statusChange = MantaroBot.getInstance().getExecutorService()
                    .scheduleAtFixedRate(Shard.this::changeStatus, 0, 10, TimeUnit.MINUTES);
        }
    };
}