Search in sources :

Example 1 with AudioQueueService

use of io.github.brendonmiranda.bot.clancy.service.AudioQueueService in project clancy by brendonmiranda.

the class PlayCmd method command.

@Override
public void command(SlashCommandEvent event) {
    OptionMapping option = event.getOption(MUSIC_ARG);
    String args = option.getAsString();
    logger.debug("PlayCmd loading track: {}", args);
    AudioPlayer audioPlayer = audioPlayerManager.createPlayer();
    audioPlayer.addListener(audioEventListener);
    Consumer<Message> success = (message) -> {
        Guild guild = event.getGuild();
        AudioManager audioManager = guild.getAudioManager();
        PlayResultHandler playResultHandler = new PlayResultHandler(audioPlayer, guild, audioManager, event, audioPlayerManager, eventWaiter, message, false, audioQueueService);
        audioPlayerManager.loadItemOrdered(event.getGuild(), args, playResultHandler);
    };
    event.replyEmbeds(MessageUtil.buildMessage("Searching...")).queue(interactionHook -> {
        interactionHook.retrieveOriginal().queue(success);
    });
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) AudioPlayer(com.sedmelluq.discord.lavaplayer.player.AudioPlayer) Message(net.dv8tion.jda.api.entities.Message) OptionType(net.dv8tion.jda.api.interactions.commands.OptionType) MessageUtil(io.github.brendonmiranda.bot.clancy.util.MessageUtil) Logger(org.slf4j.Logger) OptionData(net.dv8tion.jda.api.interactions.commands.build.OptionData) AudioManager(net.dv8tion.jda.api.managers.AudioManager) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EventWaiter(com.jagrosh.jdautilities.commons.waiter.EventWaiter) AudioPlayerManager(com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager) SlashCommandEvent(net.dv8tion.jda.api.events.interaction.SlashCommandEvent) Consumer(java.util.function.Consumer) AudioQueueService(io.github.brendonmiranda.bot.clancy.service.AudioQueueService) Component(org.springframework.stereotype.Component) PlayResultHandler(io.github.brendonmiranda.bot.clancy.listener.PlayResultHandler) Guild(net.dv8tion.jda.api.entities.Guild) OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) AudioEventListener(io.github.brendonmiranda.bot.clancy.listener.AudioEventListener) Collections(java.util.Collections) AudioManager(net.dv8tion.jda.api.managers.AudioManager) Message(net.dv8tion.jda.api.entities.Message) PlayResultHandler(io.github.brendonmiranda.bot.clancy.listener.PlayResultHandler) AudioPlayer(com.sedmelluq.discord.lavaplayer.player.AudioPlayer) Guild(net.dv8tion.jda.api.entities.Guild)

Aggregations

EventWaiter (com.jagrosh.jdautilities.commons.waiter.EventWaiter)1 AudioPlayer (com.sedmelluq.discord.lavaplayer.player.AudioPlayer)1 AudioPlayerManager (com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager)1 AudioEventListener (io.github.brendonmiranda.bot.clancy.listener.AudioEventListener)1 PlayResultHandler (io.github.brendonmiranda.bot.clancy.listener.PlayResultHandler)1 AudioQueueService (io.github.brendonmiranda.bot.clancy.service.AudioQueueService)1 MessageUtil (io.github.brendonmiranda.bot.clancy.util.MessageUtil)1 Collections (java.util.Collections)1 Consumer (java.util.function.Consumer)1 Guild (net.dv8tion.jda.api.entities.Guild)1 Message (net.dv8tion.jda.api.entities.Message)1 SlashCommandEvent (net.dv8tion.jda.api.events.interaction.SlashCommandEvent)1 OptionMapping (net.dv8tion.jda.api.interactions.commands.OptionMapping)1 OptionType (net.dv8tion.jda.api.interactions.commands.OptionType)1 OptionData (net.dv8tion.jda.api.interactions.commands.build.OptionData)1 AudioManager (net.dv8tion.jda.api.managers.AudioManager)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1