Search in sources :

Example 1 with WidgetRegistry

use of net.robinfriedli.aiode.command.widget.WidgetRegistry in project aiode by robinfriedli.

the class WidgetListener method onGuildMessageDelete.

@Override
public void onGuildMessageDelete(@NotNull GuildMessageDeleteEvent event) {
    EventHandlerPool.execute(() -> {
        WidgetRegistry widgetRegistry = guildManager.getContextForGuild(event.getGuild()).getWidgetRegistry();
        widgetRegistry.getActiveWidget(event.getMessageIdLong()).ifPresent(widget -> {
            widget.setMessageDeleted(true);
            widget.destroy();
        });
    });
}
Also used : WidgetRegistry(net.robinfriedli.aiode.command.widget.WidgetRegistry)

Example 2 with WidgetRegistry

use of net.robinfriedli.aiode.command.widget.WidgetRegistry in project aiode by robinfriedli.

the class AudioManager method createNowPlayingWidget.

void createNowPlayingWidget(CompletableFuture<Message> futureMessage, AudioPlayback playback) {
    Guild guild = playback.getGuild();
    WidgetRegistry widgetRegistry = guildManager.getContextForGuild(guild).getWidgetRegistry();
    CompletableFutures.thenAccept(futureMessage, message -> new NowPlayingWidget(widgetRegistry, guild, message).initialise());
}
Also used : WidgetRegistry(net.robinfriedli.aiode.command.widget.WidgetRegistry) Guild(net.dv8tion.jda.api.entities.Guild) NowPlayingWidget(net.robinfriedli.aiode.command.widget.widgets.NowPlayingWidget)

Example 3 with WidgetRegistry

use of net.robinfriedli.aiode.command.widget.WidgetRegistry in project aiode by robinfriedli.

the class QueueCommand method listQueue.

private void listQueue() {
    Guild guild = getContext().getGuild();
    AudioManager audioManager = Aiode.get().getAudioManager();
    AudioPlayback playback = audioManager.getPlaybackForGuild(guild);
    AudioQueue audioQueue = playback.getAudioQueue();
    CompletableFuture<Message> futureMessage = sendMessage(audioQueue.buildMessageEmbed(playback, guild));
    WidgetRegistry widgetRegistry = getContext().getGuildContext().getWidgetRegistry();
    CompletableFutures.thenAccept(futureMessage, message -> new QueueWidget(widgetRegistry, guild, message, playback).initialise());
}
Also used : AudioManager(net.robinfriedli.aiode.audio.AudioManager) AudioPlayback(net.robinfriedli.aiode.audio.AudioPlayback) Message(net.dv8tion.jda.api.entities.Message) WidgetRegistry(net.robinfriedli.aiode.command.widget.WidgetRegistry) Guild(net.dv8tion.jda.api.entities.Guild) AudioQueue(net.robinfriedli.aiode.audio.AudioQueue) QueueWidget(net.robinfriedli.aiode.command.widget.widgets.QueueWidget)

Example 4 with WidgetRegistry

use of net.robinfriedli.aiode.command.widget.WidgetRegistry in project aiode by robinfriedli.

the class WidgetListener method onGuildMessageReactionAdd.

@Override
public void onGuildMessageReactionAdd(GuildMessageReactionAddEvent event) {
    if (!event.getUser().isBot()) {
        EventHandlerPool.execute(() -> {
            long messageId = event.getMessageIdLong();
            WidgetRegistry widgetRegistry = guildManager.getContextForGuild(event.getGuild()).getWidgetRegistry();
            Optional<AbstractWidget> activeWidget = widgetRegistry.getActiveWidget(messageId);
            activeWidget.ifPresent(abstractWidget -> handleWidgetExecution(event, abstractWidget));
        });
    }
}
Also used : WidgetRegistry(net.robinfriedli.aiode.command.widget.WidgetRegistry) AbstractWidget(net.robinfriedli.aiode.command.widget.AbstractWidget)

Aggregations

WidgetRegistry (net.robinfriedli.aiode.command.widget.WidgetRegistry)4 Guild (net.dv8tion.jda.api.entities.Guild)2 Message (net.dv8tion.jda.api.entities.Message)1 AudioManager (net.robinfriedli.aiode.audio.AudioManager)1 AudioPlayback (net.robinfriedli.aiode.audio.AudioPlayback)1 AudioQueue (net.robinfriedli.aiode.audio.AudioQueue)1 AbstractWidget (net.robinfriedli.aiode.command.widget.AbstractWidget)1 NowPlayingWidget (net.robinfriedli.aiode.command.widget.widgets.NowPlayingWidget)1 QueueWidget (net.robinfriedli.aiode.command.widget.widgets.QueueWidget)1