use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.
the class AutochannelListener method onGuildVoiceJoin.
@Override
public void onGuildVoiceJoin(GuildVoiceJoinEvent e) {
VoiceChannel ch = e.getChannelJoined();
if (isAutoChannel(e.getGuild(), ch)) {
VoiceChannel newChannel = (VoiceChannel) e.getGuild().getController().createCopyOfChannel(ch).setName(ch.getName() + " [AC]").complete();
e.getGuild().getController().moveVoiceMember(e.getMember(), newChannel).queue();
}
}
use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.
the class CommandMoveAll method execute.
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
String[] args = parsedCommandInvocation.getArgs();
Message message = parsedCommandInvocation.getMessage();
Guild guild = parsedCommandInvocation.getMessage().getGuild();
if (args.length == 0) {
return createHelpMessage(parsedCommandInvocation);
}
if (!message.getMember().getVoiceState().inVoiceChannel())
return new MessageBuilder().setEmbed(EmbedUtil.error("Not connected", "Please connect to a voice channel to use this command").build()).build();
String name;
name = message.getContentRaw().replace(parsedCommandInvocation.getCommandInvocation(), "");
name = name.replace(parsedCommandInvocation.getPrefix(), "");
name = name.substring(1);
List<VoiceChannel> channels = message.getGuild().getVoiceChannelsByName(name, true);
if (channels.isEmpty())
return new MessageBuilder().setEmbed(EmbedUtil.error("Channel not found", "This channel doesen't exist").build()).build();
VoiceChannel channel = channels.get(0);
if (channel.equals(message.getMember().getVoiceState().getChannel()))
return new MessageBuilder().setEmbed(EmbedUtil.error("Same channel", "You are already connected to that channel").build()).build();
GuildController controller = message.getGuild().getController();
if (!guild.getSelfMember().hasPermission(Permission.VOICE_MOVE_OTHERS)) {
return new MessageBuilder().setEmbed(EmbedUtil.error("Cannot move you!", "Cannot move all members in the Channel").build()).build();
}
message.getMember().getVoiceState().getChannel().getMembers().forEach(m -> {
if (!parsedCommandInvocation.getSelfMember().canInteract(m))
return;
controller.moveVoiceMember(m, channel).queue();
});
return new MessageBuilder().setEmbed(EmbedUtil.success("Connected", "Connected all users in your channel to `" + channel.getName() + "`").build()).build();
}
use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.
the class CommandAutochannel method handleReaction.
public static void handleReaction(MessageReactionAddEvent event) {
if (!searches.containsKey(event.getGuild()))
return;
ChannelSearch search = searches.get(event.getGuild());
if (!event.getMessageId().equals(search.message.getId()))
return;
String emote = event.getReactionEmote().getName();
event.getReaction().removeReaction(event.getUser()).queue();
if (!search.channels.containsKey(emote))
return;
if (search.delete) {
VoiceChannel channel = search.channels.get(emote);
deleteChannel(channel, event.getTextChannel().getMessageById(event.getMessageId()).complete(), event);
} else {
VoiceChannel channel = search.channels.get(emote);
String oldEntry = RubiconBot.getMySQL().getGuildValue(event.getGuild(), "autochannels");
String newEntry = oldEntry + ", " + channel.getId();
RubiconBot.getMySQL().updateGuildValue(event.getGuild(), "autochannels", newEntry);
Message mymsg = event.getTextChannel().getMessageById(event.getMessageId()).complete().editMessage(EmbedUtil.success("Created Autochannel", "Successfully created autochannel -> " + channel.getName() + "").build()).complete();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
mymsg.delete().queue();
}
}, 5000);
}
event.getTextChannel().getMessageById(event.getMessageId()).complete().getReactions().forEach(r -> r.removeReaction().queue());
}
use of net.dv8tion.jda.core.entities.VoiceChannel in project Rubicon by Rubicon-Bot.
the class CommandAutochannel method addChannel.
public void addChannel(CommandManager.ParsedCommandInvocation parsedCommandInvocation) {
String[] args = parsedCommandInvocation.getArgs();
Guild guild = parsedCommandInvocation.getMessage().getGuild();
StringBuilder names = new StringBuilder();
for (int i = 1; i < args.length; i++) {
names.append(args[i]).append(" ");
}
String name = names.toString();
name = names.replace(name.lastIndexOf(" "), name.lastIndexOf(" ") + 1, "").toString();
List<VoiceChannel> channels = guild.getVoiceChannelsByName(name, false);
String oldEntry = RubiconBot.getMySQL().getGuildValue(guild, "autochannels");
if (channels.isEmpty()) {
Message mymsg = parsedCommandInvocation.getMessage().getTextChannel().sendMessage(EmbedUtil.error("Not found", "There is no Channel with the specified name").build()).complete();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
mymsg.delete().queue();
}
}, 5000);
return;
}
if (channels.size() > 1) {
ChannelSearch search = genChannelSearch(channels, false, parsedCommandInvocation);
searches.put(guild, search);
} else {
VoiceChannel channel = channels.get(0);
String newEntry = oldEntry + ", " + channel.getId();
RubiconBot.getMySQL().updateGuildValue(guild, "autochannels", newEntry);
Message mymsg = parsedCommandInvocation.getMessage().getChannel().sendMessage(EmbedUtil.success("Created Autochannel", "Successfully created autochannel -> " + channel.getName() + "").build()).complete();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
mymsg.delete().queue();
}
}, 5000);
}
}
use of net.dv8tion.jda.core.entities.VoiceChannel in project FredBoat by Frederikam.
the class GuildPlayer method joinChannel.
public void joinChannel(Member usr) throws MessagingException {
VoiceChannel targetChannel = getUserCurrentVoiceChannel(usr);
joinChannel(targetChannel);
}
Aggregations