Class MusicWorker

java.lang.Object
de.presti.ree6.audio.music.MusicWorker

public class MusicWorker extends Object
Wrapper class that handles most Music related stuff.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    All Guild Music Manager
    final com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager
    The AudioPlayer Manager of the Bot.
  • Constructor Summary

    Constructors
    Constructor
    Description
    The constructor of the Music-worker.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if the user has enough permission to control the bot.
    void
    connectToAudioChannel(net.dv8tion.jda.api.managers.AudioManager audioManager, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel)
    Let the Bot connect to an Audio-Channel.
    void
    disconnect(net.dv8tion.jda.api.entities.Guild guild)
    Method use to disconnect the Bot from the channel.
    getGuildAudioPlayer(net.dv8tion.jda.api.entities.Guild guild)
    Retrieve the GuildMusicManager of a Guild.
    boolean
    isAttemptingToConnect(net.dv8tion.jda.api.audio.hooks.ConnectionStatus connectionStatus)
    Check if the Bot is trying to join an Audio-Channel right now.
    boolean
    isConnected(net.dv8tion.jda.api.entities.Guild guild)
    Check if the Bot is connected to an Audio-Channel on the given Guild.
    boolean
    isConnectedMember(net.dv8tion.jda.api.entities.Member member)
    Check if the Member is connected to an Audio-Channel on the Guild.
    void
    loadAndPlay(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, boolean silent)
    Play or add a Song to the Queue with a Message.
    void
    loadAndPlay(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, boolean silent, boolean force)
    Play or add a Song to the Queue with a Message.
    void
    loadAndPlay(net.dv8tion.jda.api.entities.Guild guild, net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, boolean silent, boolean force)
    Play or add a Song to the Queue with a Message.
    void
    loadAndPlaySilence(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook)
    Play or add a Song to the Queue without a Message.
    void
    play(net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, GuildMusicManager musicManager, com.sedmelluq.discord.lavaplayer.track.AudioTrack track)
    The simple Audio play method, used to Queue songs and let the Bot join the Audio-channel if not present.
    void
    play(net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, GuildMusicManager musicManager, com.sedmelluq.discord.lavaplayer.track.AudioTrack track, boolean force)
    The simple Audio play method, used to Queue songs and let the Bot join the Audio-channel if not present.
    void
    playSong(String value, CommandEvent commandEvent)
    Play a specific song.
    void
    playSong(String value, net.dv8tion.jda.api.entities.Guild guild, net.dv8tion.jda.api.entities.Member member, net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.interactions.InteractionHook interactionHook)
    Play a specific song.
    void
    seekInTrack(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, int seekAmountInSeconds)
    A method used to seek to a specific position in the current AudioTrack.
    void
    skipTrack(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, int skipAmount)
    A method use to skip the current AudioTrack that is played.
    void
    skipTrack(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, int skipAmount, boolean silent)
    A method use to skip the current AudioTrack that is played.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • playerManager

      public final com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager playerManager
      The AudioPlayer Manager of the Bot.
    • musicManagers

      public final Map<Long,GuildMusicManager> musicManagers
      All Guild Music Manager
  • Constructor Details

    • MusicWorker

      public MusicWorker()
      The constructor of the Music-worker.
  • Method Details

    • getGuildAudioPlayer

      public GuildMusicManager getGuildAudioPlayer(net.dv8tion.jda.api.entities.Guild guild)
      Retrieve the GuildMusicManager of a Guild.
      Parameters:
      guild - the Guild.
      Returns:
      the MusicManager of that Guild.
    • loadAndPlaySilence

      public void loadAndPlaySilence(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook)
      Play or add a Song to the Queue without a Message.
      Parameters:
      channel - the TextChannel where the command has been performed, used for errors.
      audioChannel - the AudioChannel for the Bot to join.
      trackUrl - the Track URL.
      interactionHook - a InteractionHook if it was an SlashCommand.
    • loadAndPlay

      public void loadAndPlay(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, boolean silent)
      Play or add a Song to the Queue with a Message.
      Parameters:
      channel - the TextChannel where the command has been performed.
      audioChannel - the AudioChannel for the Bot to join.
      trackUrl - the Track URL.
      interactionHook - a InteractionHook if it was an SlashCommand.
      silent - if the Bot shouldn't send a Message.
    • loadAndPlay

      public void loadAndPlay(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, boolean silent, boolean force)
      Play or add a Song to the Queue with a Message.
      Parameters:
      channel - the TextChannel where the command has been performed.
      audioChannel - the AudioChannel for the Bot to join.
      trackUrl - the Track URL.
      interactionHook - a InteractionHook if it was an SlashCommand.
      silent - if the Bot shouldn't send a Message.
      force - if the song should be forced or not.
    • loadAndPlay

      public void loadAndPlay(net.dv8tion.jda.api.entities.Guild guild, net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, String trackUrl, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, boolean silent, boolean force)
      Play or add a Song to the Queue with a Message.
      Parameters:
      guild - the Guild where the command has been performed.
      channel - the TextChannel where the command has been performed.
      audioChannel - the AudioChannel for the Bot to join.
      trackUrl - the Track URL.
      interactionHook - a InteractionHook if it was an SlashCommand.
      silent - if the Bot shouldn't send a Message.
      force - if the song should be forced or not.
    • play

      public void play(net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, GuildMusicManager musicManager, com.sedmelluq.discord.lavaplayer.track.AudioTrack track)
      The simple Audio play method, used to Queue songs and let the Bot join the Audio-channel if not present.
      Parameters:
      audioChannel - the Audio-channel for the Bot.
      musicManager - the Music-Manager of the Guild.
      track - the AudioTrack that should be played.
    • play

      public void play(net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel, GuildMusicManager musicManager, com.sedmelluq.discord.lavaplayer.track.AudioTrack track, boolean force)
      The simple Audio play method, used to Queue songs and let the Bot join the Audio-channel if not present.
      Parameters:
      audioChannel - the Audio-channel for the Bot.
      musicManager - the Music-Manager of the Guild.
      track - the AudioTrack that should be played.
      force - if the Track should be played immediately.
    • playSong

      public void playSong(String value, CommandEvent commandEvent)
      Play a specific song.
      Parameters:
      value - The song name or url.
      commandEvent - The command event.
    • playSong

      public void playSong(String value, net.dv8tion.jda.api.entities.Guild guild, net.dv8tion.jda.api.entities.Member member, net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.interactions.InteractionHook interactionHook)
      Play a specific song.
      Parameters:
      value - The song name or url.
      guild - The Guild this command has been executed on.
      member - The Member that has executed this.
      channel - The channel it has been executed in.
      interactionHook - The Interaction-Hook of the member
    • skipTrack

      public void skipTrack(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, int skipAmount)
      A method use to skip the current AudioTrack that is played.
      Parameters:
      channel - the TextChannel, used to inform the user about the skip.
      interactionHook - the Interaction-Hook, used to replace the channel if it is a SlashCommand.
      skipAmount - the amount of Tracks that should be skipped.
    • skipTrack

      public void skipTrack(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, net.dv8tion.jda.api.interactions.InteractionHook interactionHook, int skipAmount, boolean silent)
      A method use to skip the current AudioTrack that is played.
      Parameters:
      channel - the TextChannel, used to inform the user about the skip.
      interactionHook - the Interaction-Hook, used to replace the channel if it is a SlashCommand.
      skipAmount - the amount of Tracks that should be skipped.
      silent - if the skip should be silent or not.
    • seekInTrack

      public void seekInTrack(net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion channel, int seekAmountInSeconds)
      A method used to seek to a specific position in the current AudioTrack.
      Parameters:
      channel - the TextChannel, used to inform the user about the seek.
      seekAmountInSeconds - the amount of seconds that should be seeked.
    • isAttemptingToConnect

      public boolean isAttemptingToConnect(net.dv8tion.jda.api.audio.hooks.ConnectionStatus connectionStatus)
      Check if the Bot is trying to join an Audio-Channel right now.
      Parameters:
      connectionStatus - the current Status of its connection.
      Returns:
      true, if it is connecting | false, if not.
    • connectToAudioChannel

      public void connectToAudioChannel(net.dv8tion.jda.api.managers.AudioManager audioManager, net.dv8tion.jda.api.entities.channel.middleman.AudioChannel audioChannel)
      Let the Bot connect to an Audio-Channel.
      Parameters:
      audioManager - the Audio-Manager of the Bot.
      audioChannel - the Audio-Channel the Bot should join.
    • isConnected

      public boolean isConnected(net.dv8tion.jda.api.entities.Guild guild)
      Check if the Bot is connected to an Audio-Channel on the given Guild.
      Parameters:
      guild - the Guild.
      Returns:
      true, if the Bot is connected to an Audio-channel | false, if not.
    • disconnect

      public void disconnect(net.dv8tion.jda.api.entities.Guild guild)
      Method use to disconnect the Bot from the channel.
      Parameters:
      guild - the Guild.
    • isConnectedMember

      public boolean isConnectedMember(net.dv8tion.jda.api.entities.Member member)
      Check if the Member is connected to an Audio-Channel on the Guild.
      Parameters:
      member - the Member.
      Returns:
      true, if the Member is connected to an Audio-channel | false, if not.
    • checkInteractPermission

      public boolean checkInteractPermission(CommandEvent commandEvent)
      Check if the user has enough permission to control the bot.
      Parameters:
      commandEvent - the CommandEvent.
      Returns:
      true, if the user has enough permission | false, if not.