Search in sources :

Example 1 with LogUtils

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

the class AudioLoader method trackLoaded.

@Override
public void trackLoaded(AudioTrack audioTrack) {
    sendTrackLoadedMessage(audioTrack);
    if (!announceMsg)
        RobertifyAudioManager.getUnannouncedTracks().add(audioTrack.getIdentifier());
    trackRequestedByUser.putIfAbsent(guild.getIdLong(), new ArrayList<>());
    trackRequestedByUser.get(guild.getIdLong()).add(sender.getId() + ":" + audioTrack.getIdentifier());
    final var scheduler = musicManager.getScheduler();
    scheduler.setAnnouncementChannel(announcementChannel);
    if (addToBeginning)
        scheduler.addToBeginningOfQueue(audioTrack);
    else
        scheduler.queue(audioTrack);
    AudioTrackInfo info = audioTrack.getInfo();
    new LogUtils().sendLog(guild, LogType.QUEUE_ADD, sender.getAsMention() + " has added `" + info.title + " by " + info.author + "` to the queue.");
    if (scheduler.playlistRepeating)
        scheduler.setSavedQueue(guild, scheduler.queue);
    if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
        new DedicatedChannelConfig().updateMessage(guild);
}
Also used : LogUtils(main.utils.json.logs.LogUtils) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig)

Example 2 with LogUtils

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

the class RemoveCommand method handleRemove.

public EmbedBuilder handleRemove(Guild guild, User remover, ConcurrentLinkedQueue<AudioTrack> queue, int id) {
    GeneralUtils.setCustomEmbed(guild, "Queue");
    final List<AudioTrack> trackList = new ArrayList<>(queue);
    if (queue.isEmpty()) {
        EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing in the queue.");
        return eb;
    }
    if (id <= 0 || id > queue.size())
        return RobertifyEmbedUtils.embedMessage(guild, "This is an invalid ID! You must provide an ID between 1 and " + queue.size());
    AudioTrack removedTrack = trackList.get(id - 1);
    AudioTrackInfo info = removedTrack.getInfo();
    EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Removed `" + info.title + "` from the queue");
    if (!queue.remove(removedTrack))
        eb = RobertifyEmbedUtils.embedMessage(guild, "Could not remove track with id " + id + " from the queue");
    else
        new LogUtils().sendLog(guild, LogType.QUEUE_REMOVE, remover.getAsMention() + " has removed `" + info.title + " by " + info.author + "` from the queue.");
    if (id <= 10)
        if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
            new DedicatedChannelConfig().updateMessage(guild);
    return eb;
}
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) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig)

Example 3 with LogUtils

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

the class RewindCommand method handleRewind.

public EmbedBuilder handleRewind(User user, GuildVoiceState selfVoiceState, long time, boolean rewindToBeginning) {
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(selfVoiceState.getGuild());
    final var audioPlayer = musicManager.getPlayer();
    final AudioTrack track = audioPlayer.getPlayingTrack();
    final var guild = selfVoiceState.getGuild();
    EmbedBuilder eb;
    if (track == null) {
        eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
        return eb;
    }
    AudioTrackInfo info = track.getInfo();
    if (info.isStream)
        return RobertifyEmbedUtils.embedMessage(guild, "You can't rewind a stream!");
    if (rewindToBeginning) {
        audioPlayer.seekTo(0L);
        eb = RobertifyEmbedUtils.embedMessage(guild, "You have rewound the song to the beginning!");
        new LogUtils().sendLog(guild, LogType.TRACK_REWIND, user.getAsMention() + " has rewound `" + info.title + " by " + info.author + "` to the beginning");
    } else {
        if (time <= 0) {
            eb = RobertifyEmbedUtils.embedMessage(guild, "The duration cannot be negative or zero!");
            return eb;
        }
        time = TimeUnit.SECONDS.toMillis(time);
        if (time > audioPlayer.getTrackPosition()) {
            eb = RobertifyEmbedUtils.embedMessage(guild, "This duration cannot be more than the current time in the song");
            return eb;
        }
        audioPlayer.seekTo(audioPlayer.getTrackPosition() - time);
        eb = RobertifyEmbedUtils.embedMessage(guild, "You have rewound the song by " + TimeUnit.MILLISECONDS.toSeconds(time) + " seconds!");
        new LogUtils().sendLog(guild, LogType.TRACK_REWIND, user.getAsMention() + " has rewound `" + info.title + " by " + info.author + "` by " + TimeUnit.MILLISECONDS.toSeconds(time) + " seconds");
    }
    return eb;
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) LogUtils(main.utils.json.logs.LogUtils) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 4 with LogUtils

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

the class ClearQueueCommand method handle.

@Override
public void handle(CommandContext ctx) throws ScriptException {
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(ctx.getGuild());
    final var queue = musicManager.getScheduler().queue;
    final Message msg = ctx.getMessage();
    final Guild guild = ctx.getGuild();
    final GuildVoiceState selfVoiceState = ctx.getGuild().getSelfMember().getVoiceState();
    GeneralUtils.setCustomEmbed(guild, "Queue");
    if (queue.isEmpty()) {
        EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "There is already nothing in the queue.");
        msg.replyEmbeds(eb.build()).queue();
        return;
    }
    if (selfVoiceState.inVoiceChannel()) {
        if (selfVoiceState.getChannel().getMembers().size() > 2) {
            if (!GeneralUtils.hasPerms(ctx.getGuild(), ctx.getMember(), Permission.ROBERTIFY_DJ)) {
                EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "You need to be a DJ to use this command when there's other users in the channel!");
                msg.replyEmbeds(eb.build()).queue();
                return;
            }
        }
    } else {
        EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "The bot isn't in a voice channel.");
        msg.replyEmbeds(eb.build()).queue();
        return;
    }
    queue.clear();
    new LogUtils().sendLog(guild, LogType.QUEUE_CLEAR, ctx.getAuthor().getAsMention() + " has cleared the queue");
    if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
        new DedicatedChannelConfig().updateMessage(guild);
    EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "The queue was cleared!");
    msg.replyEmbeds(eb.build()).queue();
    GeneralUtils.setDefaultEmbed(guild);
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Message(net.dv8tion.jda.api.entities.Message) GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) LogUtils(main.utils.json.logs.LogUtils) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig) Guild(net.dv8tion.jda.api.entities.Guild)

Example 5 with LogUtils

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

the class LoopCommand method handleQueueRepeat.

public EmbedBuilder handleQueueRepeat(GuildMusicManager musicManager, User looper, IPlayer audioPlayer, Guild guild) {
    EmbedBuilder eb;
    final var scheduler = musicManager.getScheduler();
    if (scheduler.playlistRepeating) {
        scheduler.playlistRepeating = false;
        scheduler.removeSavedQueue(guild);
        eb = RobertifyEmbedUtils.embedMessage(guild, "The current queue will no longer be repeated!");
    } else {
        scheduler.playlistRepeating = true;
        if (audioPlayer.getPlayingTrack() == null) {
            eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing currently playing!");
            return eb;
        }
        AudioTrack thisTrack = audioPlayer.getPlayingTrack();
        if (scheduler.queue.isEmpty()) {
            eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing in the queue to repeat!\n");
            return eb;
        }
        scheduler.addToBeginningOfQueue(thisTrack);
        scheduler.setSavedQueue(guild, scheduler.queue);
        scheduler.queue.remove(thisTrack);
        eb = RobertifyEmbedUtils.embedMessage(guild, "The current queue will now be looped!");
    }
    new LogUtils().sendLog(guild, LogType.TRACK_LOOP, looper.getAsMention() + " has " + (scheduler.playlistRepeating ? "looped" : "unlooped") + " the queue");
    return eb;
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) LogUtils(main.utils.json.logs.LogUtils) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

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