当前位置: 首页>>代码示例>>Java>>正文


Java MessageEmbed.TEXT_MAX_LENGTH属性代码示例

本文整理汇总了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());
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:12,代码来源:DiscordUtils.java

示例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);
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:15,代码来源:TextConverter.java

示例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);
    }
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:27,代码来源:CommandsServiceImpl.java

示例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());
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:12,代码来源:DiscordUtils.java


注:本文中的net.dv8tion.jda.core.entities.MessageEmbed.TEXT_MAX_LENGTH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。