/** * Gets a {@link TextChannel} from a string. Not case sensitive. * The string can eater be the channel name, it's id, or it being mentioned. * * @param channelArg The string to get the channel from * @param wrapper The Guild wrapper for the {@link Guild} that you want to get the channel from * @return null if the channel couldn't be found otherwise a {@link TextChannel} */ public static TextChannel getChannel(String channelArg, GuildWrapper wrapper) { try { long channelId = Long.parseLong(channelArg.replaceAll("[^0-9]", "")); return wrapper != null ? wrapper.getGuild().getTextChannelById(channelId) : Getters.getChannelById(channelId); } catch (NumberFormatException e) { if (wrapper != null) { List<TextChannel> tcs = wrapper.getGuild().getTextChannelsByName(channelArg, true); if (!tcs.isEmpty()) { return tcs.get(0); } } return null; } }
List<TextChannel> textChannelsByName = message.getGuild().getTextChannelsByName(part, true); if (!textChannelsByName.isEmpty()) { return textChannelsByName.get(0);
} else { List<TextChannel> channelList = isCrossGuild ? jda.getTextChannelsByName(argument, true) : c.issuer.getEvent().getGuild().getTextChannelsByName(argument, true); if (channelList.size() > 1) { throw new InvalidCommandArgument("Too many channels were found with the given name. Try with the `#channelname` syntax.", false);
List<TextChannel> channels = guild.getTextChannelsByName(settings.getOrDefault(GSetting.MUSIC_CHANNEL), true); if (!channels.isEmpty()) { outputChannel = channels.get(0);