• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EmbedObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中sx.blah.discord.api.internal.json.objects.EmbedObject的典型用法代码示例。如果您正苦于以下问题:Java EmbedObject类的具体用法?Java EmbedObject怎么用?Java EmbedObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EmbedObject类属于sx.blah.discord.api.internal.json.objects包,在下文中一共展示了EmbedObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAverage

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
private EmbedObject getAverage() {
	Map<String, Integer> moneyGained = StatsManager.get(MoneyEnum.MONEY_GAINED.toString());
	Map<String, Integer> commandsUsed = StatsManager.get(CommandEnum.COMMAND_USED.toString());

	if(moneyGained == null || moneyGained.isEmpty() || commandsUsed == null || commandsUsed.isEmpty()) {
		return null;
	}

	Map<String, Integer> moneyLost = StatsManager.get(MoneyEnum.MONEY_LOST.toString());

	Map<String, Pair<Float, Integer>> averageMap = new HashMap<>();
	for(String gameName : moneyGained.keySet()) {
		float average = ((float) moneyGained.get(gameName) - moneyLost.getOrDefault(gameName, 0)) / commandsUsed.get(gameName);
		averageMap.put(gameName, new Pair<Float, Integer>(average, commandsUsed.get(gameName)));
	}

	EmbedBuilder embed = EmbedUtils.getDefaultEmbed()
			.withAuthorName("Average")
			.appendField("Name", FormatUtils.format(averageMap.keySet().stream(), Object::toString, "\n"), true)
			.appendField("Average", FormatUtils.format(averageMap.values().stream().map(Pair::getFirst), num -> FormatUtils.formatNum(num.intValue()), "\n"), true)
			.appendField("Count", FormatUtils.format(averageMap.values().stream().map(Pair::getSecond), num -> FormatUtils.formatNum(num), "\n"), true);

	return embed.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:25,代码来源:StatsCmd.java


示例2: getCommandInfoEmbed

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
private EmbedObject getCommandInfoEmbed(ICommand cmd) {
      EmbedBuilder em = new EmbedBuilder();
      em.withAuthorIcon(Main.client.getGuildByID(266063520112574464L).getIconURL());
      em.withAuthorName("DisCal");
      em.appendField("Command", cmd.getCommand(), true);
      em.appendField("Description", cmd.getCommandInfo().getDescription(), true);
      em.appendField("Example", cmd.getCommandInfo().getExample(), true);

      //Loop through sub commands
      if (cmd.getCommandInfo().getSubCommands().size() > 0) {
	String subs = cmd.getCommandInfo().getSubCommands().keySet().toString();
	subs = subs.replace("[", "").replace("]", "");
	em.appendField("Sub-Commands", subs, false);
}

      em.withFooterText("<> = required | () = optional");

      em.withUrl("https://www.cloudcraftgaming.com/discal/commands");

      em.withColor(56, 138, 237);

      return em.build();
  }
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:24,代码来源:HelpCommand.java


示例3: getSubCommandEmbed

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
private EmbedObject getSubCommandEmbed(ICommand cmd, String subCommand) {
	EmbedBuilder em = new EmbedBuilder();
	em.withAuthorIcon(Main.client.getGuildByID(266063520112574464L).getIconURL());
	em.withAuthorName("DisCal");
	em.appendField("Command", cmd.getCommand(), true);
	em.appendField("Sub Command", subCommand, true);

	em.appendField("Usage", cmd.getCommandInfo().getSubCommands().get(subCommand), false);

	em.withFooterText("<> = required | () = optional");

	em.withUrl("https://www.cloudcraftgaming.com/discal/commands");

	em.withColor(56, 138, 237);

	return em.build();
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:18,代码来源:HelpCommand.java


示例4: publish

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
public void publish(String outputChannel, String id, String content, EmbedObject embedObject) {
    log.debug("Publishing a discord message and embed ({}) to output channel : {}", id, outputChannel);
    subscriberRepository.findByChannelAndType(outputChannel, "DiscordMessageEmbed").stream()
        // only include if the subscriber has allowed this time
        .filter(sub -> timeFrameService.included(sub.getId()))
        // abort if one of the target clients is not ready
        .filter(sub -> isClientReady((String) sub.getVariables().get("client")))
        // check for duplicated messages to avoid spam
        .filter(sub -> checkDuplicate(sub, id))
        .forEach(sub -> {
            String channelId = (String) sub.getVariables().get("channel");
            String clientId = (String) sub.getVariables().get("client");
            if (channelId == null) {
                log.warn("Subscriber did not define a target channel: {}", sub);
            } else {
                executeMessage(clientId, channelId, content, embedObject);
            }
        });
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:20,代码来源:SubscriberService.java


示例5: executeMessage

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
private void executeMessage(String clientId, String channelId, String content, EmbedObject embedObject) {
    clientRegistry.getClients().entrySet().stream()
        .filter(entry -> matchesClient(clientId, entry))
        .forEach(entry -> {
            IChannel channel = entry.getValue().getChannelByID(snowflake(channelId));
            if (channel != null) {
                if (content != null && content.length() > Message.MAX_MESSAGE_LENGTH) {
                    answerToChannel(channel, content, false).get();
                    if (embedObject != null) {
                        sendMessage(channel, null, embedObject);
                    }
                } else {
                    sendMessage(channel, content, embedObject);
                }
            } else {
                log.warn("Did not found a channel with id {} in bot {}", channelId, clientId);
            }
        });
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:20,代码来源:SubscriberService.java


示例6: buildEmbed

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject buildEmbed() {
	final EmbedBuilder builder = new EmbedBuilder();

	builder.appendField("震央", getRegionName(), true);
	builder.appendField("深さ", getDepth()+"km", true);
	builder.appendField("マグニチュード", String.valueOf(getMagnitude()), true);
	getIntensity().ifPresent(intensity -> builder.appendField("予想震度", intensity.getSimple(), false));

	if (isAlert())
		builder.withColor(255, 0, 0);
	else
		builder.withColor(0, 0, 255);
	builder.withTitle("緊急地震速報 ("+getAlertFlg()+") "+(isFinal() ? "最終報" : "第"+getReportNum()+"報"));
	builder.withTimestamp(getReportTime().getTime());

	builder.withFooterText("新強震モニタ");
	return builder.build();
}
 
开发者ID:Team-Fruit,项目名称:EEWBot,代码行数:20,代码来源:EEW.java


示例7: process

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public void process(CommandContext ctx) throws CommandException {
    if (draminator != null) {
        sc.callMethod(draminator, "set_file_fetcher", new Object() {
            @SuppressWarnings("unused")
            public RubyIO open(String path) {
                return new RubyIO(sc.getProvider().getRuntime(), MCBot.class.getResourceAsStream("/mcdrama/" + path));
            }
        });
        BigInteger seed = (BigInteger) sc.callMethod(sc.get("Random"), "new_seed");
        String version = (String) sc.callMethod(draminator, "current_version");
        sc.callMethod(sc.get("Random"), "srand", seed);
        String drama = (String) sc.callMethod(draminator, "draminate");
        drama = drama.replaceAll("(\\r\\n|\\r|\\n)", "");
        
        EmbedObject reply = new EmbedBuilder()
                .withTitle(ctx.getAuthor().getDisplayName(ctx.getGuild()) + " started some drama!")
                .withUrl("https://ftb-drama.herokuapp.com/" + version + "/" + seed.toString(36))
                .withDesc(drama)
                .build();
        ctx.replyBuffered(reply);
    } else {
        ctx.replyBuffered("Sorry, the drama command is not set up properly. Contact your bot admin!");
    }
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:26,代码来源:CommandDrama.java


示例8: build

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
public EmbedObject build() {
	EmbedBuilder embed = EmbedUtils.getDefaultEmbed()
			.setLenient(true)
			.withAuthorName(String.format("Help for %s command", cmd.getName()))
			.withDescription(description)
			.appendField("Usage", this.getUsage(), false)
			.appendField("Arguments", this.getArguments(), false)
			.appendField("Example", example, false)
			.appendField("Gains", gains, false)
			.appendField("Source", source, false);

	if(thumbnail != null) {
		embed.withThumbnail(thumbnail);
	}

	for(EmbedField field : fields) {
		embed.appendField(field);
	}

	if(!cmd.getAlias().isEmpty()) {
		embed.withFooterText(String.format("Alias: %s", cmd.getAlias()));
	}

	return embed.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:26,代码来源:HelpBuilder.java


示例9: sendMessage

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
/**
 * Sends a message via Discord as DisCal.
 *
 * @param embed   The EmbedObject to append to the message.
 * @param channel The channel to send the message to.
 */
public static IMessage sendMessage(EmbedObject embed, IChannel channel) {
	return RequestBuffer.request(() -> {
		try {
			return new MessageBuilder(Main.client).withEmbed(embed).withChannel(channel).build();
		} catch (DiscordException | MissingPermissionsException e) {
			//Failed to send message.
			return null;
		}
	}).get();
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:17,代码来源:Message.java


示例10: sendDirectMessage

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
public static IMessage sendDirectMessage(EmbedObject embed, IUser user) {
	return RequestBuffer.request(() -> {
		try {
			IPrivateChannel pc = user.getOrCreatePMChannel();
			return new MessageBuilder(Main.client).withChannel(pc).withEmbed(embed).build();
		} catch (DiscordException | MissingPermissionsException e) {
			//Failed to send message.
			return null;
		}
	}).get();
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:12,代码来源:Message.java


示例11: getHelp

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject getHelp(String prefix) {
	return new HelpBuilder(this, prefix)
			.setDescription("Show a random quote from DansTonChat.com")
			.setSource("https://danstonchat.com")
			.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:8,代码来源:DtcCmd.java


示例12: getPreCalendarEmbed

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
/**
 * Creates an EmbedObject for the PreCalendar.
 *
 * @param calendar The PreCalendar to create an EmbedObject for.
 * @return The EmbedObject for the PreCalendar.
 */
public static EmbedObject getPreCalendarEmbed(PreCalendar calendar, GuildSettings settings) {
	EmbedBuilder em = new EmbedBuilder();
	em.withAuthorIcon(Main.client.getGuildByID(266063520112574464L).getIconURL());
	em.withAuthorName("DisCal");
	em.withTitle(MessageManager.getMessage("Embed.Calendar.Pre.Title", settings));
	if (calendar.getSummary() != null) {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Pre.Summary", settings), calendar.getSummary(), true);
	} else {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Pre.Summary", settings), "***UNSET***", true);
	}
	if (calendar.getDescription() != null) {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Pre.Description", settings), calendar.getDescription(), false);
	} else {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Pre.Description", settings), "***UNSET***", false);
	}
	if (calendar.getTimezone() != null) {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Pre.TimeZone", settings), calendar.getTimezone(), true);
	} else {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Pre.TimeZone", settings), "***UNSET***", true);
	}
	if (calendar.isEditing()) {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Pre.CalendarId", settings), calendar.getCalendarId(), false);
	} //No else needed, just don't post it.

	em.withFooterText(MessageManager.getMessage("Embed.Calendar.Pre.Key", settings));
	em.withColor(56, 138, 237);

	return em.build();
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:36,代码来源:CalendarMessageFormatter.java


示例13: getHelp

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject getHelp(String prefix) {
	return new HelpBuilder(this, prefix)
			.setDescription("Search for a wallpaper.")
			.setUsage(String.format("[-p %s] [-c %s] [-rat %s] [-res %s] [-k %s]", PURITY, CATEGORY, RATIO, RESOLUTION, KEYWORD))
			.addArg(PURITY, FormatUtils.format(Purity.values(), purity -> purity.toString().toLowerCase(), ", "), true)
			.addArg(CATEGORY, FormatUtils.format(Category.values(), cat -> cat.toString().toLowerCase(), ", "), true)
			.addArg(RATIO, "image ratio (e.g. 16x9)", true)
			.addArg(RESOLUTION, "image resolution (e.g. 1920x1080)", true)
			.addArg(KEYWORD, "keywords (e.g. doom,game)", true)
			.setExample(String.format("Search a *SFW* wallpaper in category *Anime*, with a *16x9* ratio :"
					+ "%n`%s%s -p sfw -c anime -rat 16x9`", prefix, this.getName()))
			.setSource("https://alpha.wallhaven.cc")
			.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:16,代码来源:WallpaperCmd.java


示例14: getCondensedEventEmbed

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
/**
 * Gets an EmbedObject for the specified event.
 *
 * @param event The event involved.
 * @return The EmbedObject of the event.
 */
public static EmbedObject getCondensedEventEmbed(Event event, GuildSettings settings) {
	EmbedBuilder em = new EmbedBuilder();
	em.withAuthorIcon(Main.client.getGuildByID(266063520112574464L).getIconURL());
	em.withAuthorName("DisCal");
	em.withTitle(MessageManager.getMessage("Embed.Event.Condensed.Title", settings));
	EventData ed = DatabaseManager.getManager().getEventData(settings.getGuildID(), event.getId());
	if (ed.getImageLink() != null && ImageUtils.validate(ed.getImageLink())) {
		em.withThumbnail(ed.getImageLink());
	}
	if (event.getSummary() != null) {
		String summary = event.getSummary();
		if (summary.length() > 250) {
			summary = summary.substring(0, 250);
			summary = summary + " (continues on Google Calendar View)";
		}
		em.appendField(MessageManager.getMessage("Embed.Event.Condensed.Summary", settings), summary, true);
	}
	em.appendField(MessageManager.getMessage("Embed.Event.Condensed.Date", settings), getHumanReadableDate(event.getStart(), settings, false), true);
	if (event.getLocation() != null && !event.getLocation().equalsIgnoreCase("")) {
		if (event.getLocation().length() > 300) {
			String location = event.getLocation().substring(0, 300).trim() + "... (cont. on Google Cal)";
			em.appendField(MessageManager.getMessage("Embed.Event.Confirm.Location", settings), location, true);
		} else {
			em.appendField(MessageManager.getMessage("Embed.Event.Confirm.Location", settings), event.getLocation(), true);
		}
	}
	em.appendField(MessageManager.getMessage("Embed.Event.Condensed.ID", settings), event.getId(), false);
	em.withUrl(event.getHtmlLink());
	try {
		EventColor ec = EventColor.fromId(Integer.valueOf(event.getColorId()));
		em.withColor(ec.getR(), ec.getG(), ec.getB());
	} catch (Exception e) {
		//Color is null, ignore and add our default.
		em.withColor(56, 138, 237);
	}

	return em.build();
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:45,代码来源:EventMessageFormatter.java


示例15: getHelp

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject getHelp(String prefix) {
	return new HelpBuilder(this, prefix)
			.setDescription("Show player's stats for Counter-Strike: Global Offensive.")
			.addArg("steamID", "steam ID, custom ID or profile URL", false)
			.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:8,代码来源:CounterStrikeCmd.java


示例16: publish

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
private void publish(Flow flow, String id, String content, EmbedObject embed) {
    if (embed == null && isBlank(content)) {
        log.info("[{}] Not publishing null and/or blank content/embed to {}", flow.getName(), id);
    } else {
        subscriberService.publish(flow.getOutput(), id, content, embed);
    }
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:8,代码来源:FlowService.java


示例17: getHelp

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject getHelp(String prefix) {
	return new HelpBuilder(this, prefix)
			.setDescription("Transfer coins to the mentioned user.")
			.addArg("coins", false)
			.addArg("@user", false)
			.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:9,代码来源:TransferCoinsCmd.java


示例18: asEmbed

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject asEmbed(Map<String, Object> dataMap) {
	MessageDeleteEvent source = getSource();
	return source.getMessage().getEmbeds().stream()
			.findFirst()
			.map(EmbedObject::new)
			.orElse(null);
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:9,代码来源:MessageDeletedEvent.java


示例19: getHelp

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject getHelp(String prefix) {
	return new HelpBuilder(this, prefix)
			.setDescription("Create a poll.")
			.addArg("duration", String.format("in seconds, must be between %ds and %ds (1 hour)", MIN_DURATION, MAX_DURATION), false)
			.addArg("\"question\"", false)
			.addArg("choice1", false)
			.addArg("choice2", false)
			.addArg("choiceX", true)
			.setExample(String.format("`%s%s 120 \"Where do we eat at noon?\" \"White\" \"53\" \"A dog\"`", prefix, this.getName()))
			.appendField("Restrictions", String.format("**question and choices** - must be in quotation marks"
					+ "%n**choices** - min: %d, max: %d", MIN_CHOICES_NUM, MAX_CHOICES_NUM), false)
			.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:15,代码来源:PollCmd.java


示例20: getHelp

import sx.blah.discord.api.internal.json.objects.EmbedObject; //导入依赖的package包/类
@Override
public EmbedObject getHelp(String prefix) {
	return new HelpBuilder(this, prefix)
			.setDescription("Chat with an artificial intelligence.")
			.addArg("message", false)
			.setSource("https://pandorabots.com/"
					+ "\n**Marvin** (ID: efc39100ce34d038)"
					+ "\n**Chomsky** (ID: b0dafd24ee35a477)"
					+ "\n**R.I.V.K.A** (ID: ea373c261e3458c6)"
					+ "\n**Lisa** (ID: b0a6a41a5e345c23)")
			.build();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:13,代码来源:ChatCmd.java



注:本文中的sx.blah.discord.api.internal.json.objects.EmbedObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MCVersion类代码示例发布时间:2022-05-21
下一篇:
Java TaxonomyReader类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap