本文整理汇总了Java中sx.blah.discord.api.internal.json.objects.EmbedObject类的典型用法代码示例。如果您正苦于以下问题:Java EmbedObject类的具体用法?Java EmbedObject怎么用?Java EmbedObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmbedObject类属于sx.blah.discord.api.internal.json.objects包,在下文中一共展示了EmbedObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例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();
}
示例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);
}
});
}
示例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);
}
});
}
示例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();
}
示例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!");
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}