Search in sources :

Example 1 with InteractiveEvent

use of tk.ardentbot.core.events.InteractiveEvent in project Ardent by adamint.

the class Command method dispatchInteractiveEvent.

private static boolean dispatchInteractiveEvent(OffsetDateTime creationTime, TextChannel channel, Message message, User user, Consumer<Message> function, int time, boolean sendMessage) {
    final boolean[] success = { false };
    Pair<String, Triplet<String, String, Consumer<Message>>> p = new Pair<>(channel.getId(), new Triplet<>(user.getId(), message.getId(), function));
    InteractiveEvent e = GuildUtils.getShard(channel.getJDA()).interactiveEvent;
    e.getMessageInteractivesQueue().add(p);
    ex.schedule(() -> {
        if (e.getMessageInteractivesQueue().contains(p)) {
            e.getMessageInteractivesQueue().remove(p);
            if (sendMessage) {
                if (time >= 15) {
                    channel.sendMessage("Cancelled your interactive operation because you didn't respond within " + time + " seconds!").queue();
                } else {
                    channel.sendMessage("Cancelled your reaction event because you didn't respond within **" + String.valueOf(time / 1000) + "** seconds").queue();
                }
            }
        }
        return success[0];
    }, time, TimeUnit.SECONDS);
    return success[0];
}
Also used : Triplet(tk.ardentbot.utils.javaAdditions.Triplet) InteractiveEvent(tk.ardentbot.core.events.InteractiveEvent) Pair(kotlin.Pair)

Example 2 with InteractiveEvent

use of tk.ardentbot.core.events.InteractiveEvent in project Ardent by adamint.

the class Command method interactiveReaction.

public static void interactiveReaction(MessageChannel channel, Message message, User user, int seconds, Consumer<MessageReaction> function) {
    Pair<String, Triplet<String, String, Consumer<MessageReaction>>> p = new Pair<>(channel.getId(), new Triplet<>(user.getId(), message.getId(), function));
    InteractiveEvent e = GuildUtils.getShard(channel.getJDA()).interactiveEvent;
    e.getReactionInteractivesQueue().add(p);
    ex.schedule(() -> {
        if (e.getReactionInteractivesQueue().contains(p)) {
            e.getReactionInteractivesQueue().remove(p);
            channel.sendMessage("Cancelled your reaction event because you didn't respond in time!").queue();
        }
    }, seconds, TimeUnit.SECONDS);
}
Also used : Triplet(tk.ardentbot.utils.javaAdditions.Triplet) InteractiveEvent(tk.ardentbot.core.events.InteractiveEvent) Pair(kotlin.Pair)

Example 3 with InteractiveEvent

use of tk.ardentbot.core.events.InteractiveEvent in project Ardent by adamint.

the class Command method dispatchInteractiveEvent.

private static boolean dispatchInteractiveEvent(OffsetDateTime creationTime, TextChannel channel, Message message, Consumer<Message> function, int time, boolean sendMessage) {
    final boolean[] success = { false };
    Pair<String, Triplet<String, String, Consumer<Message>>> p = new Pair<>(channel.getId(), new Triplet<>(message.getAuthor().getId(), message.getId(), function));
    InteractiveEvent e = GuildUtils.getShard(channel.getJDA()).interactiveEvent;
    e.getMessageInteractivesQueue().add(p);
    ex.schedule(() -> {
        if (e.getMessageInteractivesQueue().contains(p)) {
            e.getMessageInteractivesQueue().remove(p);
            if (sendMessage) {
                if (time >= 15) {
                    channel.sendMessage("Cancelled your interactive operation because you didn't respond within " + time + " seconds!").queue();
                } else {
                    channel.sendMessage("Cancelled your reaction event because you didn't respond within **" + String.valueOf(time / 1000) + "** seconds").queue();
                }
            }
        }
        return success[0];
    }, time, TimeUnit.SECONDS);
    return success[0];
}
Also used : Triplet(tk.ardentbot.utils.javaAdditions.Triplet) InteractiveEvent(tk.ardentbot.core.events.InteractiveEvent) Pair(kotlin.Pair)

Aggregations

Pair (kotlin.Pair)3 InteractiveEvent (tk.ardentbot.core.events.InteractiveEvent)3 Triplet (tk.ardentbot.utils.javaAdditions.Triplet)3