Search in sources :

Example 21 with LogUtils

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

the class JumpCommand method doActualJump.

private EmbedBuilder doActualJump(Guild guild, User jumper, String input, IPlayer player, AudioTrack track) {
    long time;
    EmbedBuilder eb;
    if (GeneralUtils.stringIsInt(input))
        time = Long.parseLong(input);
    else {
        eb = RobertifyEmbedUtils.embedMessage(guild, "You must provide a valid duration to rewind");
        return eb;
    }
    if (time <= 0) {
        eb = RobertifyEmbedUtils.embedMessage(guild, "The duration cannot be negative or zero!");
        return eb;
    }
    time = TimeUnit.SECONDS.toMillis(time);
    if (time > track.getInfo().length - player.getTrackPosition()) {
        eb = RobertifyEmbedUtils.embedMessage(guild, "This duration cannot be more than the time left!");
        return eb;
    }
    player.seekTo(player.getTrackPosition() + time);
    new LogUtils().sendLog(guild, LogType.TRACK_JUMP, jumper.getAsMention() + " has jumped `" + TimeUnit.MILLISECONDS.toSeconds(time) + "` seconds.");
    return RobertifyEmbedUtils.embedMessage(guild, "Successfully jumped `" + input + "` seconds ahead!");
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) LogUtils(main.utils.json.logs.LogUtils)

Example 22 with LogUtils

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

the class LoopCommand method handleRepeat.

public EmbedBuilder handleRepeat(GuildMusicManager musicManager, User looper) {
    final var guild = musicManager.getGuild();
    final var player = musicManager.getPlayer();
    final var scheduler = musicManager.getScheduler();
    if (player.getPlayingTrack() == null)
        return RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
    EmbedBuilder eb;
    AudioTrackInfo info = player.getPlayingTrack().getInfo();
    if (scheduler.repeating) {
        scheduler.repeating = false;
        eb = RobertifyEmbedUtils.embedMessage(guild, "`" + info.title + "` will no longer be looped!");
    } else {
        scheduler.repeating = true;
        eb = RobertifyEmbedUtils.embedMessage(guild, "`" + info.title + "` will now be looped");
    }
    new LogUtils().sendLog(guild, LogType.TRACK_LOOP, looper.getAsMention() + " has " + (scheduler.repeating ? "looped" : "unlooped") + " `" + info.title + " by " + info.author + "`");
    return eb;
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) LogUtils(main.utils.json.logs.LogUtils) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 23 with LogUtils

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

the class MoveCommand method handleMove.

public EmbedBuilder handleMove(Guild guild, User mover, ConcurrentLinkedQueue<AudioTrack> queue, int id, int position) {
    GeneralUtils.setCustomEmbed(guild, "Queue");
    if (queue.isEmpty())
        return RobertifyEmbedUtils.embedMessage(guild, "There is nothing in the queue.");
    final List<AudioTrack> trackList = new ArrayList<>(queue);
    if (id <= 0 || id > trackList.size()) {
        EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "That isn't a valid song id.");
        return eb;
    } else if (position <= 0 || position > trackList.size()) {
        EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "That isn't a valid position id.");
        return eb;
    }
    final List<AudioTrack> prevList = new ArrayList<>(queue);
    queue.clear();
    prevList.remove(trackList.get(id - 1));
    prevList.add(position - 1, trackList.get(id - 1));
    if (!queue.addAll(prevList)) {
        queue.addAll(trackList);
        return RobertifyEmbedUtils.embedMessage(guild, "Could not move track with id " + id + " in the queue");
    }
    if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
        new DedicatedChannelConfig().updateMessage(guild);
    AudioTrackInfo info = trackList.get(id - 1).getInfo();
    new LogUtils().sendLog(guild, LogType.TRACK_MOVE, mover.getAsMention() + " has moved `" + info.title + " by " + info.author + "` to position `" + position + "`");
    return RobertifyEmbedUtils.embedMessage(guild, "Moved `" + info.title + "` to position `" + position + "`.");
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) ArrayList(java.util.ArrayList) LogUtils(main.utils.json.logs.LogUtils) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 24 with LogUtils

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

the class PauseCommand method handlePauseEvent.

public EmbedBuilder handlePauseEvent(Guild guild, GuildVoiceState selfVoiceState, GuildVoiceState memberVoiceState) {
    EmbedBuilder eb;
    if (!selfVoiceState.inVoiceChannel()) {
        eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
        return eb;
    }
    if (!memberVoiceState.inVoiceChannel()) {
        eb = RobertifyEmbedUtils.embedMessage(guild, "You need to be in a voice channel for this to work");
        return eb;
    }
    if (!memberVoiceState.getChannel().equals(selfVoiceState.getChannel())) {
        eb = RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command!" + "\n\nI am currently in: " + selfVoiceState.getChannel().getAsMention());
        return eb;
    }
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
    final var audioPlayer = musicManager.getPlayer();
    if (audioPlayer.getPlayingTrack() == null) {
        eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing");
        return eb;
    }
    if (audioPlayer.isPaused()) {
        audioPlayer.setPaused(false);
        musicManager.setForcePaused(false);
        eb = RobertifyEmbedUtils.embedMessage(guild, "You have resumed the music!");
        new LogUtils().sendLog(guild, LogType.PLAYER_RESUME, memberVoiceState.getMember().getAsMention() + " has resumed the music");
    } else {
        audioPlayer.setPaused(true);
        musicManager.setForcePaused(true);
        eb = RobertifyEmbedUtils.embedMessage(guild, "You have paused the music!");
        new LogUtils().sendLog(guild, LogType.PLAYER_PAUSE, memberVoiceState.getMember().getAsMention() + " has paused the music");
    }
    return eb;
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) LogUtils(main.utils.json.logs.LogUtils)

Example 25 with LogUtils

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

the class KaraokeFilter method handle.

@Override
public void handle(CommandContext ctx) throws ScriptException {
    final var guild = ctx.getGuild();
    final var msg = ctx.getMessage();
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
    final var audioPlayer = musicManager.getPlayer();
    final var filters = audioPlayer.getFilters();
    final var selfMember = ctx.getSelfMember();
    if (!selfMember.getVoiceState().inVoiceChannel()) {
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "I must be in a voice channel in order for this command to work!").build()).queue();
        return;
    }
    GuildVoiceState memberVoiceState = ctx.getMember().getVoiceState();
    if (!memberVoiceState.inVoiceChannel()) {
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).queue();
        return;
    }
    if (!memberVoiceState.getChannel().equals(selfMember.getVoiceState().getChannel())) {
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).queue();
        return;
    }
    if (filters.getKaraoke() != null) {
        filters.setKaraoke(null).commit();
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **Karaoke** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Karaoke filter off");
    } else {
        filters.setKaraoke(new Karaoke()).commit();
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **Karaoke** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Karaoke filter ofn");
    }
}
Also used : GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) LogUtils(main.utils.json.logs.LogUtils) Karaoke(lavalink.client.io.filters.Karaoke)

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