Search in sources :

Example 16 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState 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 17 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState in project Robertify-Bot by bombies.

the class PauseCommand method handle.

@Override
public void handle(CommandContext ctx) throws ScriptException {
    final Message msg = ctx.getMessage();
    final Member self = ctx.getSelfMember();
    final GuildVoiceState selfVoiceState = self.getVoiceState();
    final Member member = ctx.getMember();
    final GuildVoiceState memberVoiceState = member.getVoiceState();
    msg.replyEmbeds(handlePauseEvent(ctx.getGuild(), selfVoiceState, memberVoiceState).build()).queue();
}
Also used : Message(net.dv8tion.jda.api.entities.Message) GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) Member(net.dv8tion.jda.api.entities.Member)

Example 18 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState in project Robertify-Bot by bombies.

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

Example 19 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState in project Robertify-Bot by bombies.

the class EightDFilter 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.getRotation() != null) {
        filters.setRotation(null).commit();
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **8D** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().getAsMention() + " has turned the 8D filter off");
    } else {
        filters.setRotation(new Rotation().setFrequency(0.05F)).commit();
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **8D** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().getAsMention() + " has turned the 8D filter on");
    }
}
Also used : GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) LogUtils(main.utils.json.logs.LogUtils) Rotation(lavalink.client.io.filters.Rotation)

Example 20 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState in project Robertify-Bot by bombies.

the class NightcoreFilter 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.getTimescale() != null) {
        filters.setTimescale(null).commit();
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **Nightcore** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().getAsMention() + " has turned the Nightcore filter off");
    } else {
        filters.setTimescale(new Timescale().setPitch(1.5F)).commit();
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **Nightcore** filter").build()).queue();
        new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().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)

Aggregations

GuildVoiceState (net.dv8tion.jda.api.entities.GuildVoiceState)51 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)16 Member (net.dv8tion.jda.api.entities.Member)16 LogUtils (main.utils.json.logs.LogUtils)13 AudioManager (net.dv8tion.jda.api.managers.AudioManager)12 Guild (net.dv8tion.jda.api.entities.Guild)11 TextChannel (net.dv8tion.jda.api.entities.TextChannel)9 VoiceChannel (net.dv8tion.jda.api.entities.VoiceChannel)9 ArrayList (java.util.ArrayList)7 Permission (net.dv8tion.jda.api.Permission)5 CommandFlag (at.xirado.bean.command.CommandFlag)4 SlashCommand (at.xirado.bean.command.SlashCommand)4 SlashCommandContext (at.xirado.bean.command.SlashCommandContext)4 EmbedUtil (at.xirado.bean.misc.EmbedUtil)4 Message (net.dv8tion.jda.api.entities.Message)4 Bean (at.xirado.bean.Bean)3 GenericCommand (at.xirado.bean.command.GenericCommand)3 MessageContextCommand (at.xirado.bean.command.context.MessageContextCommand)3 UserContextCommand (at.xirado.bean.command.context.UserContextCommand)3 MockContextMenuCommand (at.xirado.bean.command.context.message.MockContextMenuCommand)3