Search in sources :

Example 1 with DedicatedChannelConfig

use of main.utils.json.dedicatedchannel.DedicatedChannelConfig in project Robertify-Bot by bombies.

the class AudioLoader method sendTrackLoadedMessage.

private void sendTrackLoadedMessage(AudioTrack audioTrack) {
    EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Added to queue: `" + audioTrack.getInfo().title + "` by `" + audioTrack.getInfo().author + "`");
    if (botMsg != null) {
        if (LofiCommand.getLofiEnabledGuilds().contains(guild.getIdLong()) && LofiCommand.getAnnounceLofiMode().contains(guild.getIdLong())) {
            LofiCommand.getAnnounceLofiMode().remove(guild.getIdLong());
            botMsg.editMessageEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have enabled Lo-Fi mode").build()).queue();
        } else {
            botMsg.editMessageEmbeds(eb.build()).queue(success -> success.editMessageComponents().queue());
        }
    } else {
        if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
            new DedicatedChannelConfig().getTextChannel(guild.getIdLong()).sendMessageEmbeds(eb.build()).queue();
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig)

Example 2 with DedicatedChannelConfig

use of main.utils.json.dedicatedchannel.DedicatedChannelConfig 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 3 with DedicatedChannelConfig

use of main.utils.json.dedicatedchannel.DedicatedChannelConfig 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 4 with DedicatedChannelConfig

use of main.utils.json.dedicatedchannel.DedicatedChannelConfig 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 DedicatedChannelConfig

use of main.utils.json.dedicatedchannel.DedicatedChannelConfig in project Robertify-Bot by bombies.

the class SetChannelCommand method handle.

@Override
public void handle(CommandContext ctx) throws ScriptException {
    if (!GeneralUtils.hasPerms(ctx.getGuild(), ctx.getMember(), Permission.ROBERTIFY_ADMIN))
        return;
    final List<String> args = ctx.getArgs();
    final Message msg = ctx.getMessage();
    final Guild guild = ctx.getGuild();
    var guildConfig = new GuildConfig();
    if (args.isEmpty()) {
        TextChannel channel = ctx.getChannel();
        if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
            if (channel.getIdLong() == new DedicatedChannelConfig().getChannelID(guild.getIdLong())) {
                msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "The announcement channel cannot be set to this channel!").build()).queue();
                return;
            }
        if (guildConfig.getAnnouncementChannelID(guild.getIdLong()) == channel.getIdLong()) {
            EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "This is already the announcement channel.");
            msg.replyEmbeds(eb.build()).queue();
        } else {
            guildConfig.setAnnouncementChannelID(guild.getIdLong(), channel.getIdLong());
            EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Set the announcement channel to: " + channel.getAsMention());
            msg.replyEmbeds(eb.build()).queue();
        }
    } else {
        String id = GeneralUtils.getDigitsOnly(args.get(0));
        if (!GeneralUtils.stringIsID(id)) {
            EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "ID provided isn't a valid ID!\n" + "Make sure to either **mention** the channel, or provide its **ID**").setImage("https://i.imgur.com/Qg0BQ3f.png");
            msg.replyEmbeds(eb.build()).queue();
            return;
        }
        TextChannel channel = Robertify.shardManager.getGuildById(guild.getIdLong()).getTextChannelById(id);
        if (channel == null) {
            EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "That ID doesn't belong to any channel in this guild!");
            msg.replyEmbeds(eb.build()).queue();
            return;
        }
        if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
            if (channel.getIdLong() == new DedicatedChannelConfig().getChannelID(guild.getIdLong())) {
                msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "The announcement channel cannot be set to that channel!").build()).queue();
                return;
            }
        guildConfig.setAnnouncementChannelID(guild.getIdLong(), channel.getIdLong());
        EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "You've set the announcement channel to: " + channel.getAsMention());
        msg.replyEmbeds(eb.build()).queue();
    }
}
Also used : TextChannel(net.dv8tion.jda.api.entities.TextChannel) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Message(net.dv8tion.jda.api.entities.Message) GuildConfig(main.utils.json.guildconfig.GuildConfig) DedicatedChannelConfig(main.utils.json.dedicatedchannel.DedicatedChannelConfig) Guild(net.dv8tion.jda.api.entities.Guild)

Aggregations

DedicatedChannelConfig (main.utils.json.dedicatedchannel.DedicatedChannelConfig)14 LogUtils (main.utils.json.logs.LogUtils)9 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)7 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)6 ArrayList (java.util.ArrayList)5 Guild (net.dv8tion.jda.api.entities.Guild)5 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)4 TextChannel (net.dv8tion.jda.api.entities.TextChannel)4 Message (net.dv8tion.jda.api.entities.Message)3 LogConfig (main.utils.json.logs.LogConfig)2 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)1 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)1 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Stack (java.util.Stack)1 TimeUnit (java.util.concurrent.TimeUnit)1 GuildMusicManager (main.audiohandlers.GuildMusicManager)1 RobertifyAudioManager (main.audiohandlers.RobertifyAudioManager)1 AutoPlayException (main.exceptions.AutoPlayException)1