本文整理汇总了Java中net.dv8tion.jda.core.entities.MessageEmbed.TEXT_MAX_LENGTH属性的典型用法代码示例。如果您正苦于以下问题:Java MessageEmbed.TEXT_MAX_LENGTH属性的具体用法?Java MessageEmbed.TEXT_MAX_LENGTH怎么用?Java MessageEmbed.TEXT_MAX_LENGTH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.dv8tion.jda.core.entities.MessageEmbed
的用法示例。
在下文中一共展示了MessageEmbed.TEXT_MAX_LENGTH属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: embedList
public static <T> Pair<String, Integer> embedList(List<T> list, Function<T, String> toString) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
String s = toString.apply(list.get(i));
if (b.length() + s.length() + 5 > MessageEmbed.TEXT_MAX_LENGTH) return Pair.of(b.toString(), i);
b.append('[').append(i + 1).append("] ");
b.append(s);
b.append("\n");
}
return Pair.of(b.toString(), list.size());
}
示例2: append
private void append(CharSequence sequence) {
if (limitCheck) {
if (endReached) {
return;
}
if (textBuilder.length() + sequence.length() > MessageEmbed.TEXT_MAX_LENGTH) {
endReached = true;
if (textBuilder.length() + 3 <= MessageEmbed.TEXT_MAX_LENGTH) {
textBuilder.append("...");
}
return;
}
}
textBuilder.append(sequence);
}
示例3: sendMessage
@Override
public void sendMessage(MessageReceivedEvent event, MessageSender sender) {
JDA jda = event.getJDA();
if (event.getAuthor().isBot()) {
return;
}
GuildConfig guildConfig = null;
if (event.getChannelType().isGuild() && event.getGuild() != null) {
guildConfig = configService.getOrCreate(event.getGuild());
}
String content = event.getMessage().getRawContent().trim();
String prefix = guildConfig != null ? guildConfig.getPrefix() : configService.getDefaultPrefix();
if (event.getMessage().isMentioned(jda.getSelfUser())) {
String customMention = String.format("<@!%s>", jda.getSelfUser().getId());
prefix = content.startsWith(customMention) ? customMention : jda.getSelfUser().getAsMention();
}
if (StringUtils.isNotEmpty(content) && content.startsWith(prefix) && content.length() <= MessageEmbed.TEXT_MAX_LENGTH) {
String input = content.substring(prefix.length()).trim();
String[] args = input.split("\\s+");
if (args.length == 0) {
return;
}
input = input.substring(args[0].length(), input.length()).trim();
sender.sendCommand(event, input, args[0], guildConfig);
}
}
示例4: embedList
public static <T> Pair<String, Integer> embedList(List<T> list, Function<T, String> toString) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
String s = toString.apply(list.get(i));
if (b.length() + s.length() + 5 > MessageEmbed.TEXT_MAX_LENGTH) return new Pair<>(b.toString(), i);
b.append('[').append(i + 1).append("] ");
b.append(s);
b.append("\n");
}
return new Pair<>(b.toString(), list.size());
}