use of net.dv8tion.jda.core.entities.VoiceChannel in project TheLighterBot by PhotonBursted.
the class FileController method retrievePermChannels.
private void retrievePermChannels() throws SQLException {
retrieveData("SELECT *\n" + "FROM \"PermChannels\"", result -> {
try {
TextChannel tc = l.getBot().getTextChannelById(result.getLong("tc_id"));
VoiceChannel vc = l.getBot().getVoiceChannelById(result.getLong("vc_id"));
if (tc != null && vc != null) {
l.getChannelController().getPermChannels().putStoring(tc, vc);
}
} catch (SQLException ex) {
log.error("Something went wrong retrieving the permanent channels", ex);
}
});
}
use of net.dv8tion.jda.core.entities.VoiceChannel in project TheLighterBot by PhotonBursted.
the class UnlinkChannelCommand method execute.
@Override
protected void execute() {
if (!ev.getMember().getVoiceState().inVoiceChannel()) {
handleError(MessageContent.NOT_IN_VOICE_CHANNEL);
}
VoiceChannel vc = ev.getMember().getVoiceState().getChannel();
if (!l.getChannelController().isLinked(vc)) {
handleError(MessageContent.CHANNEL_NOT_LINKED);
}
TextChannel tc = l.getChannelController().getLinkedChannels().getForVoiceChannel(vc);
l.getChannelController().getLinkedChannels().removeByValueStoring(vc);
if (l.getChannelController().isPermanent(vc)) {
l.getChannelController().getPermChannels().removeByValueStoring(vc);
}
LoggerUtils.logAndDelete(log, String.format("A link has been removed:\n" + " - VC: %s (%s)\n" + " - TC: %s (%s)", vc.getName(), vc.getId(), tc.getName(), tc.getId()));
l.getDiscordController().sendMessage(ev, String.format("Successfully unlinked **%s** from **%s**!", vc.getName(), tc.getAsMention()), DiscordController.AUTOMATIC_REMOVAL_INTERVAL);
}
use of net.dv8tion.jda.core.entities.VoiceChannel in project legendarybot by greatman.
the class PlayMusicCommand method execute.
@Override
public void execute(MessageReceivedEvent event, String[] args) {
if (!event.getMember().getVoiceState().inVoiceChannel()) {
event.getChannel().sendMessage("You need to be yourself in a voice channel!").queue();
return;
}
String musicChannel = plugin.getBot().getGuildSettings(event.getGuild()).getSetting(MusicPlugin.MUSIC_CHANNEL_SETTING);
VoiceChannel voiceChannel;
if (musicChannel != null) {
List<VoiceChannel> channels = event.getGuild().getVoiceChannelsByName(musicChannel, false);
if (channels.isEmpty()) {
event.getChannel().sendMessage("The channel the bot can play in doesn't exist anymore. Please ask an admin to fix it with the ``setmusicchannel`` command.").queue();
return;
}
voiceChannel = channels.get(0);
} else {
voiceChannel = event.getMember().getVoiceState().getChannel();
}
plugin.getMusicManager().loadAndPlay(event.getTextChannel(), args[0], voiceChannel);
}
Aggregations