Java 类net.dv8tion.jda.core.entities.impl.MessageEmbedImpl 实例源码

项目:JuniperBotJ    文件:WebHookMessage.java   
public JSONObject toJSONObject() {
    JSONObject obj = new JSONObject();
    if (username != null)
        obj.put("username", username);
    if (avatarUrl != null)
        obj.put("avatar_url", avatarUrl);
    if (content != null)
        obj.put("content", content);
    if (CollectionUtils.isNotEmpty(embeds)) {
        JSONArray array = new JSONArray();
        embeds.stream()
                .map(e -> (MessageEmbedImpl) e)
                .forEach(e -> array.put(e.toJSONObject()));
        obj.put("embeds", array);
    }
    return obj;
}
项目:NapBot    文件:CommandCreate.java   
@Override
public boolean execute(User user, TextChannel channel, String command, List<String> parameters, Message message) throws Exception
{
    if (parameters.size() < 1)
    {
        channel.sendMessage("You need to specify a series of time ranges to create a napchart. For example: `" + NapBot.CONFIGURATION.messagePrefix + "create 03:00-05:00 08:00-08:20 14:00-14:20 21:00-23:00`").complete();
        return true;
    }
    PayloadInner payloadInner = new PayloadInner();
    for (String parameter : parameters)
    {
        Matcher matcher = this.TIMESTAMP_PATTERN.matcher(parameter);
        if (matcher.matches())
        {
            int startH = Integer.parseInt(matcher.group(2));
            int startM = Integer.parseInt(matcher.group(3));
            int endH = Integer.parseInt(matcher.group(5));
            int endM = Integer.parseInt(matcher.group(6));
            payloadInner.addSleepBlock(startH, startM, endH, endM);
        }
        else
        {
            channel.sendMessage("`" + parameter + "` doesn't seem to be a valid time range.\n\nYou need to specify a series of time ranges to create a napchart. For example: `" + NapBot.CONFIGURATION.messagePrefix + "create 03:00-05:00 08:00-08:20 14:00-14:20 21:00-23:00`").complete();
            return true;
        }
    }
    payloadInner.finalize();
    Payload payload = new Payload(payloadInner);
    String napchartID = Communicator.basicJsonMessage("Generate napchart", "https://napchart.com/api/create", payload, PayloadResponse.class, false).id;
    try
    {
        NapchartHandler.getNapchart(napchartID);
    }
    catch (IOException e)
    {
        // yay.
        e.printStackTrace();
    }
    MessageBuilder b = new MessageBuilder();
    MessageEmbedImpl embedimpl = new MessageEmbedImpl();
    embedimpl.setTitle("https://napchart.com/" + napchartID);
    embedimpl.setUrl("https://napchart.com/" + napchartID);
    embedimpl.setImage(new ImageInfo(NapBot.CONFIGURATION.napchartUrlPrefix + napchartID + "?" + NapBot.RESYNC_ID, null, 560, 560));
    embedimpl.setFields(new ArrayList<MessageEmbed.Field>());
    b.setEmbed(embedimpl);
    channel.sendMessage(b.build()).complete();
    return true;
}