Search in sources :

Example 21 with GuildVoiceState

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

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

Example 22 with GuildVoiceState

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

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

Example 23 with GuildVoiceState

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

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

Example 24 with GuildVoiceState

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

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

Example 25 with GuildVoiceState

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

the class ShufflePlaySlashCommand method onSlashCommand.

@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
    if (!checks(event))
        return;
    sendRandomMessage(event);
    EmbedBuilder eb;
    final Guild guild = event.getGuild();
    final TextChannel channel = event.getTextChannel();
    final Member member = event.getMember();
    final GuildVoiceState memberVoiceState = member.getVoiceState();
    final GuildVoiceState selfVoiceState = event.getGuild().getSelfMember().getVoiceState();
    if (!memberVoiceState.inVoiceChannel()) {
        eb = RobertifyEmbedUtils.embedMessage(event.getGuild(), "You need to be in a voice channel for this to work");
        event.replyEmbeds(eb.build()).setEphemeral(true).queue();
        return;
    }
    if (selfVoiceState.inVoiceChannel() && !memberVoiceState.getChannel().equals(selfVoiceState.getChannel())) {
        event.replyEmbeds(RobertifyEmbedUtils.embedMessage(event.getGuild(), "You must be in the same voice channel as me to use this command!" + "\n\nI am currently in: " + selfVoiceState.getChannel().getAsMention()).build()).queue();
        return;
    }
    String url = event.getOption("playlist").getAsString();
    if (!url.contains("deezer.page.link")) {
        if (url.contains("soundcloud.com") && !url.contains("sets")) {
            event.replyEmbeds(RobertifyEmbedUtils.embedMessage(event.getGuild(), "This SoundCloud URL doesn't contain a playlist!").build()).queue();
            return;
        } else if (url.contains("youtube.com") && !url.contains("playlist") && !url.contains("list")) {
            event.replyEmbeds(RobertifyEmbedUtils.embedMessage(event.getGuild(), "This YouTube URL doesn't contain a playlist!").build()).queue();
            return;
        } else if (!url.contains("playlist") && !url.contains("album") && !url.contains("soundcloud.com") && !url.contains("youtube.com")) {
            event.replyEmbeds(RobertifyEmbedUtils.embedMessage(event.getGuild(), "You must provide the link of a valid album/playlist!").build()).queue();
            return;
        }
    }
    event.deferReply().queue();
    event.getHook().sendMessageEmbeds(RobertifyEmbedUtils.embedMessage(event.getGuild(), "Adding to queue...").build()).queue(addingMsg -> {
        RobertifyAudioManager.getInstance().loadAndPlayShuffled(url, selfVoiceState, memberVoiceState, addingMsg, event, false);
    });
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) TextChannel(net.dv8tion.jda.api.entities.TextChannel) GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) Guild(net.dv8tion.jda.api.entities.Guild) Member(net.dv8tion.jda.api.entities.Member)

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