Skip to content

SchedulingTasks

literallyfiro edited this page Feb 10, 2026 · 2 revisions

Scheduling tasks

If you want to schedule tasks to be executed withing another thread, you can use the Scheduler interface. The Scheduler interface provides a way to create and submit tasks to be executed without resorting to manual thread management.

Creating a new task

In order to create a new task, you can use the buildTask method:

bot.getScheduler().buildTask(() -> {
    System.out.println("This task will be executed once after 10 seconds");
}).delay(10, TimeUnit.SECONDS).schedule();

It will return a Task class that you can use for stuff like closing the scheduled task.

See the javadoc for more information.

Clone this wiki locally