Search in sources :

Example 26 with LogUtils

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

the class KaraokeFilter method onSlashCommand.

@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
    if (!checksWithPremium(event))
        return;
    sendRandomMessage(event);
    final var guild = event.getGuild();
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
    final var audioPlayer = musicManager.getPlayer();
    final var filters = audioPlayer.getFilters();
    final var selfMember = guild.getSelfMember();
    if (!selfMember.getVoiceState().inVoiceChannel()) {
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "I must be in a voice channel in order for this command to work!").build()).setEphemeral(true).queue();
        return;
    }
    GuildVoiceState memberVoiceState = event.getMember().getVoiceState();
    if (!memberVoiceState.inVoiceChannel()) {
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).setEphemeral(true).queue();
        return;
    }
    if (!memberVoiceState.getChannel().equals(selfMember.getVoiceState().getChannel())) {
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).setEphemeral(true).queue();
        return;
    }
    if (filters.getKaraoke() != null) {
        filters.setKaraoke(null).commit();
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **Karaoke** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().getAsMention() + " has turned the Karaoke filter off");
    } else {
        filters.setKaraoke(new Karaoke()).commit();
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **Karaoke** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().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)

Example 27 with LogUtils

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

the class NightcoreFilter 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.getTimescale() != null) {
        filters.setTimescale(null).commit();
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **Nightcore** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Nightcore filter off");
    } else {
        filters.setTimescale(new Timescale().setPitch(1.5F)).commit();
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **Nightcore** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Nightcore filter on");
    }
}
Also used : GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) LogUtils(main.utils.json.logs.LogUtils) Timescale(lavalink.client.io.filters.Timescale)

Example 28 with LogUtils

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

the class StopCommand method handleStop.

public EmbedBuilder handleStop(Member stopper) {
    Guild guild = stopper.getGuild();
    final var selfVoiceState = guild.getSelfMember().getVoiceState();
    final var memberVoiceState = stopper.getVoiceState();
    if (!selfVoiceState.inVoiceChannel())
        return RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
    if (!memberVoiceState.inVoiceChannel())
        return RobertifyEmbedUtils.embedMessage(guild, "You need to be in a voice channel for this to work");
    if (!memberVoiceState.getChannel().equals(selfVoiceState.getChannel()))
        return 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());
    ;
    final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
    final var audioPlayer = musicManager.getPlayer();
    final var scheduler = musicManager.getScheduler();
    final AudioTrack track = audioPlayer.getPlayingTrack();
    if (track == null)
        return RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
    scheduler.repeating = false;
    scheduler.playlistRepeating = false;
    audioPlayer.stopTrack();
    scheduler.queue.clear();
    scheduler.getPastQueue().clear();
    if (audioPlayer.isPaused())
        audioPlayer.setPaused(false);
    if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
        new DedicatedChannelConfig().updateMessage(guild);
    LofiCommand.getLofiEnabledGuilds().remove(guild.getIdLong());
    new LogUtils().sendLog(guild, LogType.PLAYER_STOP, stopper.getAsMention() + " has stopped the player");
    scheduler.scheduleDisconnect(true);
    return RobertifyEmbedUtils.embedMessage(guild, "You have stopped the track and cleared the queue.");
}
Also used : LogUtils(main.utils.json.logs.LogUtils) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig)

Example 29 with LogUtils

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

the class LogCommand method onSlashCommand.

@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
    if (!checks(event))
        return;
    final Guild guild = event.getGuild();
    try {
        new LogUtils().createChannel(guild);
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "Successfully created the log channel!").build()).queue();
    } catch (IllegalArgumentException e) {
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "The log channel has already been setup!").build()).queue();
    }
}
Also used : LogUtils(main.utils.json.logs.LogUtils) Guild(net.dv8tion.jda.api.entities.Guild)

Example 30 with LogUtils

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

the class AudioLoader method playlistLoaded.

@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
    List<AudioTrack> tracks = audioPlaylist.getTracks();
    if (audioPlaylist.isSearchResult()) {
        sendTrackLoadedMessage(tracks.get(0));
        if (!announceMsg)
            RobertifyAudioManager.getUnannouncedTracks().add(tracks.get(0).getIdentifier());
        if (sender != null) {
            trackRequestedByUser.putIfAbsent(guild.getIdLong(), new ArrayList<>());
            trackRequestedByUser.get(guild.getIdLong()).add(sender.getId() + ":" + tracks.get(0).getIdentifier());
        }
        final var scheduler = musicManager.getScheduler();
        scheduler.setAnnouncementChannel(announcementChannel);
        if (addToBeginning)
            scheduler.addToBeginningOfQueue(tracks.get(0));
        else
            scheduler.queue(tracks.get(0));
        AudioTrackInfo info = tracks.get(0).getInfo();
        if (sender != null)
            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);
    } else {
        EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Added to queue: `" + tracks.size() + "` tracks from `" + audioPlaylist.getName() + "`");
        if (botMsg != null)
            botMsg.editMessageEmbeds(eb.build()).queue();
        else {
            new DedicatedChannelConfig().getTextChannel(guild.getIdLong()).sendMessageEmbeds(eb.build()).queue();
        }
        if (!announceMsg)
            for (final AudioTrack track : tracks) RobertifyAudioManager.getUnannouncedTracks().add(track.getIdentifier());
        if (loadPlaylistShuffled)
            Collections.shuffle(tracks);
        final var scheduler = musicManager.getScheduler();
        scheduler.setAnnouncementChannel(announcementChannel);
        if (addToBeginning)
            scheduler.addToBeginningOfQueue(tracks);
        if (sender != null) {
            trackRequestedByUser.putIfAbsent(guild.getIdLong(), new ArrayList<>());
            new LogUtils().sendLog(guild, LogType.QUEUE_ADD, sender.getAsMention() + " has added `" + audioPlaylist.getTracks().size() + "` songs from playlist `" + audioPlaylist.getName() + "` to the queue.");
        }
        for (final AudioTrack track : tracks) {
            if (sender != null)
                trackRequestedByUser.get(guild.getIdLong()).add(sender.getId() + ":" + track.getIdentifier());
            if (!addToBeginning)
                scheduler.queue(track);
        }
        if (scheduler.playlistRepeating)
            scheduler.setSavedQueue(guild, scheduler.queue);
        if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
            new DedicatedChannelConfig().updateMessage(guild);
    }
}
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) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig)

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