use of dev.cerus.mapads.discordbot.listener.ButtonInteractListener in project map-ads by cerus-mc.
the class DiscordBot method start.
public CompletableFuture<Void> start() {
final CompletableFuture<Void> future = new CompletableFuture<>();
this.executorService.execute(() -> {
try {
this.jda = JDABuilder.createDefault(this.config.token, Arrays.asList(GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_MESSAGES)).addEventListeners(new MessageDeleteListener(this.storage), new ButtonInteractListener(this.storage, this.config, this.callback)).build().awaitReady();
Activity.ActivityType type;
try {
type = Activity.ActivityType.valueOf(this.config.activityType);
} catch (final IllegalArgumentException ignored) {
type = Activity.ActivityType.LISTENING;
}
OnlineStatus status;
try {
status = OnlineStatus.valueOf(this.config.onlineStatus);
} catch (final IllegalArgumentException ignored) {
status = OnlineStatus.ONLINE;
}
final Activity activity = Activity.of(type, this.config.activityString);
this.jda.getPresence().setPresence(status, activity);
future.complete(null);
} catch (final InterruptedException | LoginException e) {
future.completeExceptionally(e);
}
});
return future;
}
Aggregations