use of net.dv8tion.jda.api.entities.GuildVoiceState in project Robertify-Bot by bombies.
the class KaraokeFilter 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.getKaraoke() != null) {
filters.setKaraoke(null).commit();
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **Karaoke** filter").build()).queue();
new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Karaoke filter off");
} else {
filters.setKaraoke(new Karaoke()).commit();
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **Karaoke** filter").build()).queue();
new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Karaoke filter ofn");
}
}
use of net.dv8tion.jda.api.entities.GuildVoiceState 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");
}
}
use of net.dv8tion.jda.api.entities.GuildVoiceState 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");
}
}
use of net.dv8tion.jda.api.entities.GuildVoiceState in project Robertify-Bot by bombies.
the class RewindCommand method handle.
@Override
public void handle(CommandContext ctx) throws ScriptException {
final Message msg = ctx.getMessage();
final Member self = ctx.getSelfMember();
GuildVoiceState selfVoiceState = self.getVoiceState();
EmbedBuilder eb;
final Member member = ctx.getMember();
final GuildVoiceState memberVoiceState = member.getVoiceState();
if (checks(selfVoiceState, memberVoiceState) != null) {
msg.replyEmbeds(checks(selfVoiceState, memberVoiceState).build()).queue();
return;
}
final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(ctx.getGuild());
final var audioPlayer = musicManager.getPlayer();
final var track = audioPlayer.getPlayingTrack();
final var guild = ctx.getGuild();
if (track == null) {
eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
msg.replyEmbeds(eb.build()).queue();
return;
}
long time = -1;
if (!ctx.getArgs().isEmpty()) {
if (GeneralUtils.stringIsInt(ctx.getArgs().get(0)))
time = Long.parseLong(ctx.getArgs().get(0));
else {
eb = RobertifyEmbedUtils.embedMessage(guild, "You must provide a valid duration to rewind");
msg.replyEmbeds(eb.build()).queue();
return;
}
}
msg.replyEmbeds(handleRewind(ctx.getAuthor(), selfVoiceState, time, ctx.getArgs().isEmpty()).build()).queue();
}
use of net.dv8tion.jda.api.entities.GuildVoiceState in project Robertify-Bot by bombies.
the class NowPlayingSlashCommand method onSlashCommand.
@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
if (!checks(event))
return;
sendRandomMessage(event);
event.deferReply().queue();
final GuildVoiceState memberVoiceState = event.getMember().getVoiceState();
final GuildVoiceState selfVoiceState = event.getGuild().getSelfMember().getVoiceState();
event.getHook().sendMessageEmbeds(new NowPlayingCommand().getNowPlayingEmbed(event.getGuild(), event.getTextChannel(), selfVoiceState, memberVoiceState).build()).setEphemeral(false).queue();
}
Aggregations