Search in sources :

Example 11 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState in project ascent_bot by FeroniK.

the class Leave method handle.

@Override
@SuppressWarnings("ConstantConditions")
public void handle(CommandContext ctx) {
    final TextChannel channel = ctx.getChannel();
    final Member member = ctx.getMember();
    final GuildVoiceState memberVoiceState = member.getVoiceState();
    GuildMusicManager musicManager = PlayerManager.getInstance().getMusicManager(ctx.getGuild());
    musicManager.scheduler.isRepeating = false;
    musicManager.scheduler.queue.clear();
    musicManager.scheduler.player.startTrack(null, false);
    AudioManager audioManager = ctx.getGuild().getAudioManager();
    audioManager.closeAudioConnection();
    String desc = "Disconnected from " + memberVoiceState.getChannel().getAsMention();
    EmbedBuilder builder = Embeds.createBuilder("Disconnected", desc, "Requested by " + member.getEffectiveName(), member.getEffectiveAvatarUrl(), null);
    channel.sendMessageEmbeds(builder.build()).queue();
}
Also used : AudioManager(net.dv8tion.jda.api.managers.AudioManager) TextChannel(net.dv8tion.jda.api.entities.TextChannel) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) GuildMusicManager(me.fero.ascent.lavaplayer.GuildMusicManager) GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) Member(net.dv8tion.jda.api.entities.Member)

Example 12 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState in project aiode by robinfriedli.

the class RewindAction method doRun.

@Override
public void doRun() {
    AudioQueue queue = audioPlayback.getAudioQueue();
    if (!queue.isEmpty()) {
        if (queue.hasPrevious()) {
            queue.reverse();
        }
        Guild guild = getContext().getGuild();
        GuildVoiceState voiceState = getContext().getMember().getVoiceState();
        audioManager.startPlayback(guild, voiceState != null ? voiceState.getChannel() : null);
    }
}
Also used : GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) Guild(net.dv8tion.jda.api.entities.Guild) AudioQueue(net.robinfriedli.aiode.audio.AudioQueue)

Example 13 with GuildVoiceState

use of net.dv8tion.jda.api.entities.GuildVoiceState in project aiode by robinfriedli.

the class SkipAction method doRun.

@Override
public void doRun() {
    AudioQueue queue = audioPlayback.getAudioQueue();
    if (!queue.isEmpty()) {
        Guild guild = getContext().getGuild();
        if (queue.hasNext()) {
            queue.iterate();
            GuildVoiceState voiceState = getContext().getMember().getVoiceState();
            audioManager.startPlayback(guild, voiceState != null ? voiceState.getChannel() : null);
        } else {
            audioPlayback.stop();
            queue.reset();
        }
    }
}
Also used : GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState) Guild(net.dv8tion.jda.api.entities.Guild) AudioQueue(net.robinfriedli.aiode.audio.AudioQueue)

Example 14 with GuildVoiceState

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

the class SeekCommand method handle.

@Override
public void handle(CommandContext ctx) throws ScriptException {
    final List<String> args = ctx.getArgs();
    final Message msg = ctx.getMessage();
    final var guild = ctx.getGuild();
    if (args.isEmpty()) {
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must provide the position you would like to jump to").build()).queue();
        return;
    }
    var position = ctx.getArgs().get(0);
    if (Pattern.matches("^\\d{1,2}:\\d{2}$", position)) {
        String[] positionSplit = position.split(":");
        int mins = Integer.parseInt(positionSplit[0]);
        int secs = Integer.parseInt(positionSplit[1]);
        final GuildVoiceState memberVoiceState = ctx.getMember().getVoiceState();
        final GuildVoiceState selfVoiceState = ctx.getSelfMember().getVoiceState();
        msg.replyEmbeds(handleSeek(selfVoiceState, memberVoiceState, mins, secs).build()).queue();
    } else if (Pattern.matches("^\\d{1,2}:\\d{1,2}:\\d{2}$", position)) {
        String[] positionSplit = position.split(":");
        int hours = Integer.parseInt(positionSplit[0]);
        int mins = Integer.parseInt(positionSplit[1]);
        int secs = Integer.parseInt(positionSplit[2]);
        final GuildVoiceState memberVoiceState = ctx.getMember().getVoiceState();
        final GuildVoiceState selfVoiceState = ctx.getSelfMember().getVoiceState();
        msg.replyEmbeds(handleSeek(selfVoiceState, memberVoiceState, hours, mins, secs).build()).queue();
    } else {
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must provide the position in the format `mm:ss` **OR** `hh:mm:ss`").build()).queue();
        return;
    }
}
Also used : Message(net.dv8tion.jda.api.entities.Message) GuildVoiceState(net.dv8tion.jda.api.entities.GuildVoiceState)

Example 15 with GuildVoiceState

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

the class VolumeCommand method handle.

@Override
public void handle(CommandContext ctx) throws ScriptException {
    final Message msg = ctx.getMessage();
    final var guild = ctx.getGuild();
    if (ctx.getArgs().isEmpty()) {
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must provide what volume you'd like to set the bot to").build()).queue();
        return;
    }
    if (!GeneralUtils.stringIsInt(ctx.getArgs().get(0))) {
        msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must provide an integer as the volume").build()).queue();
        return;
    }
    final int volume = Integer.parseInt(ctx.getArgs().get(0));
    final Member member = ctx.getMember();
    final GuildVoiceState memberVoiceState = member.getVoiceState();
    final GuildVoiceState selfVoiceState = ctx.getSelfMember().getVoiceState();
    msg.replyEmbeds(handleVolumeChange(selfVoiceState, memberVoiceState, volume).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)

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