Search in sources :

Example 16 with LogUtils

use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.

the class SeekCommand method handleSeek.

public EmbedBuilder handleSeek(GuildVoiceState selfVoiceState, GuildVoiceState memberVoiceState, int mins, int sec) {
    final var guild = selfVoiceState.getGuild();
    if (!selfVoiceState.inVoiceChannel())
        return RobertifyEmbedUtils.embedMessage(guild, "I must be in a voice channel for this command to work");
    if (!memberVoiceState.inVoiceChannel())
        return RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel I am in order to use this command");
    if (memberVoiceState.getChannel().getIdLong() != selfVoiceState.getChannel().getIdLong())
        return RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel I am in order to use this command");
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(selfVoiceState.getGuild());
    final var audioPlayer = musicManager.getPlayer();
    if (audioPlayer.getPlayingTrack() == null)
        return RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
    if (mins < 0 || mins > 59)
        return RobertifyEmbedUtils.embedMessage(guild, "You must provide a valid amount of minutes.");
    if (sec < 0 || sec > 59)
        return RobertifyEmbedUtils.embedMessage(guild, "You must provide a valid amount of seconds.");
    long totalDurationInMillis = TimeUnit.MINUTES.toMillis(mins) + TimeUnit.SECONDS.toMillis(sec);
    AudioTrackInfo info = audioPlayer.getPlayingTrack().getInfo();
    if (totalDurationInMillis > info.length)
        return RobertifyEmbedUtils.embedMessage(guild, "The position provided is greater than the length of the playing track");
    audioPlayer.seekTo(totalDurationInMillis);
    new LogUtils().sendLog(guild, LogType.TRACK_SEEK, memberVoiceState.getMember().getAsMention() + " has seeked `" + (mins > 9 ? mins : "0" + mins) + ":" + (sec > 9 ? sec : "0" + sec) + "` on `" + info.title + " by " + info.author + "`");
    return RobertifyEmbedUtils.embedMessage(guild, "You have seeked `" + (mins > 9 ? mins : "0" + mins) + ":" + (sec > 9 ? sec : "0" + sec) + "`!");
}
Also used : LogUtils(main.utils.json.logs.LogUtils) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 17 with LogUtils

use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.

the class ShuffleCommand method handleShuffle.

public EmbedBuilder handleShuffle(Guild guild, User shuffler) {
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
    final var queue = musicManager.getScheduler().queue;
    if (queue.isEmpty())
        return RobertifyEmbedUtils.embedMessage(guild, "There is nothing in the queue.");
    final List<AudioTrack> trackList = new ArrayList<>(queue);
    Collections.shuffle(trackList);
    queue.clear();
    queue.addAll(trackList);
    if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
        new DedicatedChannelConfig().updateMessage(guild);
    new LogUtils().sendLog(guild, LogType.QUEUE_SHUFFLE, shuffler.getAsMention() + " has shuffled the queue");
    return RobertifyEmbedUtils.embedMessage(guild, "Shuffled the queue!");
}
Also used : ArrayList(java.util.ArrayList) LogUtils(main.utils.json.logs.LogUtils) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig)

Example 18 with LogUtils

use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.

the class SkipToCommand method handleSkip.

public EmbedBuilder handleSkip(User skipper, ConcurrentLinkedQueue<AudioTrack> queue, GuildMusicManager musicManager, int id) {
    if (id > queue.size() || id <= 0)
        return RobertifyEmbedUtils.embedMessage(musicManager.getGuild(), "ID provided isn't a valid ID!");
    final var audioPlayer = musicManager.getPlayer();
    final var scheduler = musicManager.getScheduler();
    final var guild = musicManager.getGuild();
    List<AudioTrack> currentQueue = new ArrayList<>(queue);
    List<AudioTrack> songsToRemoveFromQueue = new ArrayList<>();
    for (int i = 0; i < id - 1; i++) songsToRemoveFromQueue.add(currentQueue.get(i));
    queue.removeAll(songsToRemoveFromQueue);
    audioPlayer.seekTo(0);
    HashMap<Long, Stack<AudioTrack>> pastQueue = scheduler.getPastQueue();
    if (!pastQueue.containsKey(guild.getIdLong()))
        pastQueue.put(guild.getIdLong(), new Stack<>());
    AudioTrack playingTrack = audioPlayer.getPlayingTrack();
    pastQueue.get(guild.getIdLong()).push(playingTrack);
    try {
        scheduler.nextTrack(playingTrack, true, playingTrack.getPosition());
    } catch (AutoPlayException ignored) {
    }
    if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
        new DedicatedChannelConfig().updateMessage(guild);
    LofiCommand.getLofiEnabledGuilds().remove(guild.getIdLong());
    new LogUtils().sendLog(guild, LogType.TRACK_SKIP, skipper.getAsMention() + " has skipped to `track #" + id + "`");
    SkipCommand.clearVoteSkipInfo(guild);
    return RobertifyEmbedUtils.embedMessage(musicManager.getGuild(), "Skipped to **track #" + id + "**!");
}
Also used : ArrayList(java.util.ArrayList) LogUtils(main.utils.json.logs.LogUtils) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AutoPlayException(main.exceptions.AutoPlayException) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig) Stack(java.util.Stack)

Example 19 with LogUtils

use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.

the class VolumeCommand method handleVolumeChange.

public EmbedBuilder handleVolumeChange(GuildVoiceState selfVoiceState, GuildVoiceState memberVoiceState, int volume) {
    final var guild = selfVoiceState.getGuild();
    if (!selfVoiceState.inVoiceChannel())
        return RobertifyEmbedUtils.embedMessage(guild, "You can't use this command while I'm not in a voice channel");
    if (memberVoiceState.inVoiceChannel() && !memberVoiceState.getChannel().equals(selfVoiceState.getChannel()))
        return RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as I am to use this command");
    if (volume < 0 || volume > 100)
        return RobertifyEmbedUtils.embedMessage(guild, "You can't set the volume to that value");
    var musicManager = RobertifyAudioManager.getInstance().getMusicManager(memberVoiceState.getGuild());
    var audioPlayer = musicManager.getPlayer();
    audioPlayer.getFilters().setVolume((float) volume / 100).commit();
    if (new DedicatedChannelConfig().isChannelSet(selfVoiceState.getGuild().getIdLong()))
        new DedicatedChannelConfig().updateMessage(selfVoiceState.getGuild());
    new LogUtils().sendLog(guild, LogType.VOLUME_CHANGE, memberVoiceState.getMember().getAsMention() + " has changed the volume to `" + volume + "%`");
    return RobertifyEmbedUtils.embedMessage(guild, "🔊  You have set the volume of the bot to **" + volume + "%**");
}
Also used : LogUtils(main.utils.json.logs.LogUtils) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig)

Example 20 with LogUtils

use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.

the class DisconnectCommand method handleDisconnect.

public EmbedBuilder handleDisconnect(Guild guild, User disconnecter) {
    var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
    musicManager.leave();
    new LogUtils().sendLog(guild, LogType.BOT_DISCONNECTED, disconnecter.getAsMention() + " has disconnected the bot.");
    return RobertifyEmbedUtils.embedMessage(guild, "Disconnected!");
}
Also used : LogUtils(main.utils.json.logs.LogUtils)

Aggregations

LogUtils (main.utils.json.logs.LogUtils)30 GuildVoiceState (net.dv8tion.jda.api.entities.GuildVoiceState)13 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)11 DedicatedChannelConfig (main.utils.json.dedicatedchannel.DedicatedChannelConfig)9 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)8 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)7 ArrayList (java.util.ArrayList)4 Guild (net.dv8tion.jda.api.entities.Guild)4 Karaoke (lavalink.client.io.filters.Karaoke)2 Rotation (lavalink.client.io.filters.Rotation)2 Timescale (lavalink.client.io.filters.Timescale)2 Tremolo (lavalink.client.io.filters.Tremolo)2 Vibrato (lavalink.client.io.filters.Vibrato)2 Message (net.dv8tion.jda.api.entities.Message)2 Stack (java.util.Stack)1 AutoPlayException (main.exceptions.AutoPlayException)1