@Override protected void doCommand(CommandEvent event) { EmbedBuilder builder = new EmbedBuilder(); builder.setColor(event.getSelfMember().getColor()); builder.setTitle("Server Traffic"); builder.addField(new MessageEmbed.Field("Traffic", MDCBot.trafficManager.getTrafficData().getRatio() + "/10", true)); if(event.getArgs().equalsIgnoreCase("details")) { builder.addField(new MessageEmbed.Field("Current ratio", String.valueOf(MDCBot.trafficManager.getTrafficData().getRatio()), true)); builder.addField(new MessageEmbed.Field("Max ratio", String.valueOf(TrafficManagerKt.getMaxRatio()), true)); builder.addField(new MessageEmbed.Field("#Messages", String.valueOf(MDCBot.trafficManager.getTrafficData().getMessages()), true)); builder.addField(new MessageEmbed.Field("#Users", String.valueOf(MDCBot.trafficManager.getTrafficData().getPlayers()), true)); } reply(event, builder.build()); }
@Override public void action(String prefix, String[] args, MessageReceivedEvent event) { Guild guild = event.getGuild(); List<String> scheduleIds = Main.getScheduleManager().getSchedulesForGuild(guild.getId()); // build output main body String content = ""; for(String sId : scheduleIds) { content += "<#" + sId + "> - has " + Main.getEntryManager().getEntriesFromChannel(sId).size() + " events\n"; } String title = "Schedules on " + guild.getName(); // title for embed String footer = scheduleIds.size() + " schedule(s)"; // footer for embed // build embed MessageEmbed embed = new EmbedBuilder() .setDescription(content) .setTitle(title) .setFooter(footer, null).build(); Message message = new MessageBuilder().setEmbed(embed).build(); // build message MessageUtilities.sendMsg(message, event.getTextChannel(), null); // send message }
public Result run(String[] args, MessageReceivedEvent e) { //Send a request to Mojang String payload = "{\"metricKeys\":[\"item_sold_minecraft\",\"prepaid_card_redeemed_minecraft\"]}"; String request = RequestUtils.post("https://api.mojang.com/orders/statistics", payload); if (request == null) { return new Result(Outcome.ERROR, ":x: The Mojang API could not be reached."); } //Extract JSON data JSONObject sales = new JSONObject(request); int total = sales.getInt("total"); int last24h = sales.getInt("last24h"); double velocity = 3600 * sales.getDouble("saleVelocityPerSeconds"); //Build and format message String m = "**Total Sales:** " + format(total) + "\n" + "**Last 24 Hours:** " + format(last24h) + "\n" + "**Sales Per Hour:** " + format(velocity); MessageEmbed me = MessageUtils.embedMessage("Minecraft Sales", null, m, Color.GREEN); return new Result(Outcome.SUCCESS, me); }
public Result run(String[] args, MessageReceivedEvent e) { //Iterate over commands String m = ""; for (Command c : Registry.commands) { CommandInfo ci = c.getInfo(); if ("".equals(ci.name)) {continue;} //Build message m += "`" + Config.getPrefix() + ci.name + "` **-** " + c.uses + "\n"; } m = m.substring(0, m.length() - 1); String title = "Command usage for " + DateUtils.getUptime(); MessageEmbed me = MessageUtils.embedMessage(title, null, m, Color.GREEN); return new Result(Outcome.SUCCESS, me); }
public static MessageEmbed buildGoLiveEmbed(BTBBeamChannel channel) { return new EmbedBuilder() .setTitle(String.format("%s is now live!", channel.user.username), String.format("https://beam.pro/%s", channel.user.username)) .setThumbnail(String.format("https://beam.pro/api/v1/users/%d/avatar?_=%d", channel.user.id, new Random().nextInt())) .setDescription(StringUtils.isBlank(channel.user.bio) ? "No bio" : channel.user.bio) .addField(channel.name, channel.type == null ? "No game selected" : channel.type.name, false) .addField("Followers", Integer.toString(channel.numFollowers), true) .addField("Views", Integer.toString(channel.viewersTotal), true) .addField("Rating", Enums.serializedName(channel.audience), true) .setImage(String.format("https://thumbs.beam.pro/channel/%d.small.jpg?_=%d", channel.id, new Random().nextInt())) .setFooter("Beam.pro", CommandHelper.BEAM_LOGO_URL).setTimestamp(Instant.now()) .setColor(CommandHelper.COLOR).build(); }
@Override public void replyAndKeep(Config config, CommandEvent commandEvent, String message) { if (config != null && config.getReplyInDmWhenPossible()) { commandEvent.replyInDM(message); commandEvent.reactSuccess(); handleOriginMessage(commandEvent); } else { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setAuthor(null, null, null); embedBuilder.setTitle(null); embedBuilder.setDescription(message); final MessageEmbed messageEmbed = embedBuilder.build(); replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed, BotServerMain.timeToRemoveFeedbackInSeconds * 3, TimeUnit.SECONDS); } }
@Override public boolean doCommand(MessageReceivedEvent message, BotContext context, String query) { LocalMember localMember = memberService.getOrCreate(message.getMember()); MemberBio bio = bioRepository.findByMember(localMember); if (bio == null) { bio = new MemberBio(); bio.setMember(localMember); } if (StringUtils.isEmpty(query)) { EmbedBuilder builder = messageService.getBaseEmbed(true); if (StringUtils.isNotEmpty(bio.getBio())) { builder.appendDescription(bio.getBio()).appendDescription("\n\n--------\n"); } builder.appendDescription(messageService.getMessage("discord.command.bio.info", context.getConfig().getPrefix())); messageService.sendMessageSilent(message.getChannel()::sendMessage, builder.build()); return true; } bio.setBio("-".equals(query) ? null : CommonUtils.trimTo(query.trim(), MessageEmbed.TEXT_MAX_LENGTH - 500)); bioRepository.save(bio); return ok(message, "discord.command.bio.updated", context.getConfig().getPrefix()); }
private MessageEmbed renderArticle(Article article, boolean redirected) { if (article == null || StringUtils.isEmpty(article.getRevisionId())) { return null; } EngProcessedPage processedPage = processedPage(article); String redirect = lookupRedirect(processedPage); if (redirect != null) { if (redirected) { return null; } return renderArticle(getArticle(redirect), true); } EmbedBuilder embedBuilder = messageService.getBaseEmbed(); try { embedBuilder.setTitle(article.getTitle(), WIKI_URL + UriUtils.encode(article.getTitle(), "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } TextConverter converter = new TextConverter(config, embedBuilder); return (MessageEmbed) converter.go(processedPage.getPage()); }
@Override public void reply(Config config, CommandEvent commandEvent, String message, int numberOfSecondsBeforeRemove, LocaleService localeService) { Validate.isTrue(numberOfSecondsBeforeRemove > 5); if (config != null && config.getReplyInDmWhenPossible()) { commandEvent.replyInDM(message); commandEvent.reactSuccess(); handleOriginMessage(commandEvent); } else { commandEvent.reactSuccess(); EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setAuthor(null, null, null); embedBuilder.setTitle(null); embedBuilder.setDescription(message); final String msgRemoveText = localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN, localeService.getLocaleForUser(commandEvent.getAuthor()), "" + numberOfSecondsBeforeRemove); embedBuilder.setFooter(msgRemoveText, null); final MessageEmbed messageEmbed = embedBuilder.build(); replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed, numberOfSecondsBeforeRemove, TimeUnit.SECONDS); } }
@Override public void reply(Config config, CommandEvent commandEvent, String message) { if (config != null && config.getReplyInDmWhenPossible()) { commandEvent.replyInDM(message); commandEvent.reactSuccess(); handleOriginMessage(commandEvent); } else { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setAuthor(null, null, null); embedBuilder.setTitle(null); embedBuilder.setDescription(message); final MessageEmbed messageEmbed = embedBuilder.build(); replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed, BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS); } }
private static MessageEmbed bot(GuildMessageReceivedEvent event, BotInfo[] infos) { if (infos.length == 0 || infos[0] == null) { return new EmbedBuilder() .setDescription("No bot that matches the specified criteria found") .setColor(event.getMember().getColor()) .setTitle("No bot found") .build(); } BotInfo info = infos[0]; return new EmbedBuilder() .setAuthor(info.getUsername() + "#" + info.getDiscriminatorString(), null, "https://images.discordapp.net/avatars/" + info.getId() + "/" + (info.getAvatar() == null ? info.getDefaultAvatar() : info.getAvatar()) + ".png?size=512" ) .setDescription("\u200D") .setTitle("Bot Info") .addField("ID", "" + info.getId(), true) .addField("Prefix", info.getPrefix().replace("*", "\\*").replace("_", "\\_").replace("~", "\\~").replace("`", "\\`"), true) .addField("Invite", "[Click here](" + info.getInvite() + ")", true) .addField("Owner" + (info.getOwners().length == 1 ? "" : "s"), Arrays.stream(info.getOwners()).mapToObj(id -> event.getGuild().getMemberById(id) != null ? "<@" + id + ">" : getName(id)).collect(Collectors.joining("\n")), true) .addField("Short Description", info.getShortDescription(), false) .addField("Shard Count", info.getShardCount() == -1 ? "Unavailable" : "" + info.getShardCount(), true) .addField("Guild Count", info.getServerCount() == -1 ? "Unavailable" : "" + info.getServerCount(), true) .addField("Upvotes", "" + info.getPoints(), true) .addField("Lib", info.getLib(), true) .addField("Certified", "" + info.isCertified(), true) .setThumbnail( "https://images.discordapp.net/avatars/" + info.getId() + "/" + (info.getAvatar() == null ? info.getDefaultAvatar() : info.getAvatar()) + ".png?size=512" ) .setColor(event.getMember().getColor()) .setFooter(infos.length > 1 ? "Best match out of " + infos.length : "Only bot that matches", null) .build(); }
@Override public Message sendAndWaitMessage(MessageEmbed message_) { try { if (isPrivate()) { return Util.sendAndWaitPrivateMessage(message.getAuthor(), message_); } else { return message.getChannel().sendMessage(message_).complete(); } } catch (Exception ex) { if (DEBUG) { ex.printStackTrace(); } return null; } }
public static final boolean sendPrivateMessage(User user, MessageEmbed message) { try { final PrivateChannel privateChannel = user.openPrivateChannel().complete(); privateChannel.sendMessage(message).queue(); privateChannel.close(); return true; } catch (Exception ex) { System.err.println(ex); return false; } }
public static final Message sendAndWaitPrivateMessage(User user, MessageEmbed message) { try { final PrivateChannel privateChannel = user.openPrivateChannel().complete(); final Message temp = privateChannel.sendMessage(message).complete(); privateChannel.close(); return temp; } catch (Exception ex) { System.err.println(ex); return null; } }
public static final String embedMessageToString(MessageEmbed message) { if (message == null) { return ""; } final StringBuilder temp = new StringBuilder(); temp.append("[EmbedType: ").append(message.getType()).append("] "); if (message.getColor() != null) { temp.append("[Color: #").append(Integer.toHexString(message.getColor().getRGB()).substring(2)).append(", Alpha: ").append(Integer.toHexString(message.getColor().getRGB()).substring(0, 2)).append("] "); } else { temp.append("[Color: null] "); } temp.append("[Title: ").append(message.getTitle()).append("] "); temp.append("[Description: ").append(message.getDescription()).append("] "); if (message.getThumbnail() != null) { temp.append("[").append(String.format("Thumbnail: %s (W: %d, H: %d)", message.getThumbnail().getProxyUrl(), message.getThumbnail().getWidth(), message.getThumbnail().getHeight())).append("] "); } if (message.getImage() != null) { temp.append("[").append(String.format("Image: %s (W: %d, H: %d)", message.getImage().getProxyUrl(), message.getImage().getWidth(), message.getImage().getHeight())).append("] "); } if (message.getSiteProvider() != null) { temp.append("[SiteProvider: ").append(message.getSiteProvider().getName()).append(" (").append(message.getSiteProvider().getUrl()).append(")] "); } if (message.getUrl() != null) { temp.append("[Url: ").append(message.getUrl()).append(")] "); } if (message.getVideoInfo() != null) { temp.append("[").append(String.format("VideoInfo: %s (W: %d, H: %d)", message.getVideoInfo().getUrl(), message.getVideoInfo().getWidth(), message.getVideoInfo().getHeight())).append("] "); } temp.append("[").append(message.getFields().stream().map((field) -> String.format("[%s; %s; %b]", field.getName(), field.getValue(), field.isInline())).collect(Collectors.joining(", "))).append("] "); if (message.getFooter() != null) { temp.append("[Footer: ").append(message.getFooter().getText()).append(" (").append(message.getFooter().getProxyIconUrl()).append(")] "); } return temp.toString(); }
public static final MessageEmbed generateMessage(boolean live, boolean ip) { final EmbedBuilder builder = Standard.getMessageEmbed(Color.YELLOW, Standard.toBold((live ? "Live " : "") + "System Information")) .addField(String.format("%s Version", Standard.STANDARD_NAME), Standard.VERSION, false) .addField("Java Version", System.getProperty("java.version"), false); if (ip) { builder.addField("IP Address", NetworkUtil.getIPAddress(), false); } builder.addField("CPU Cores available", "" + Runtime.getRuntime().availableProcessors(), false) .addField("Max Memory", getMemory(Runtime.getRuntime().maxMemory()), false) .addField("Total Memory", getMemory(Runtime.getRuntime().totalMemory()), false) .addField("Free Memory", getMemory(Runtime.getRuntime().freeMemory()), false) .addField("Local Server Time", Standard.STANDARD_DATE_TIME_FORMATTER.format(LocalDateTime.now()), false) .addField("Converted Time", Standard.STANDARD_DATE_TIME_FORMATTER.format(LocalDateTime.now(Standard.getZoneId())), false); return builder.build(); }
static MessageEmbed helpEmbed(String name, CommandPermission permission, String description, String usage) { String cmdname = Character.toUpperCase(name.charAt(0)) + name.substring(1) + " Command"; String p = permission.name().toLowerCase(); String perm = Character.toUpperCase(p.charAt(0)) + p.substring(1); return new EmbedBuilder() .setTitle(cmdname, null) .setDescription("\u200B") .addField("Permission required", perm, false) .addField("Description", description, false) .addField("Usage", usage, false) .build(); }
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()); }
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()); }
/** * Creates a simple embedded message */ public static MessageEmbed createEmbedMessage(Color colour, @Nullable String title, @Nullable String description) { EmbedBuilder builder = new EmbedBuilder(); builder.setColor(colour); if(title != null) builder.setTitle(title); if(description != null) builder.setDescription(description); return builder.build(); }
@Override protected void doCommand(CommandEvent event) { Guild guild = event.getGuild(); String args = event.getArgs(); if(args.isEmpty()) fail(event, getUsageEmbed(guild)); MessageEmbed usage = MDCBot.getCommandUsage(guild, args); reply(event, usage != null ? usage : Util.createBotMessage(guild, "Command has no usage description")); }
@Override public void reply(Config config, CommandEvent commandEvent, MessageEmbed message) { if (config != null && config.getReplyInDmWhenPossible()) { commandEvent.replyInDM(message); commandEvent.reactSuccess(); } else { commandEvent.reply(message); } }
/** * Formats an image to look more fancy using an embed. * @param title The title or header. * @param url The URL of the image. * @param color The color of the embed. Discord markdown formatting and newline are supported. * @return A MessageEmbed representing the message. You can add additional info (e.g. fields) by passing this variable into a new EmbedBuilder. */ public static MessageEmbed embedImage(String title, String url, Color color) { EmbedBuilder eb = new EmbedBuilder(); if (title != null) {eb.setAuthor(title, null, null);} eb.setImage(url); eb.setColor(color); eb = addFooter(eb); return eb.build(); }
@Override public void replyMap(Config config, CommandEvent commandEvent, MessageEmbed message) { if (config != null && config.getReplyInDmWhenPossible()) { commandEvent.replyInDM(message); commandEvent.reactSuccess(); handleOriginMessage(commandEvent); } else { commandEvent.getChannel().sendMessage(message).queue(m -> { m.delete().queueAfter(BotServerMain.timeToRemoveFeedbackInSeconds * 4, TimeUnit.SECONDS); }); commandEvent.getChannel().deleteMessageById(commandEvent.getMessage().getId()).queueAfter( BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS ); } }
public void handleThrowable(final Throwable throwable, final String context) { try{ if (this.webhook == null) return; final String trace = ExceptionUtils.getTrace(throwable); final String message = String.format("```\n%.2000s```", trace.replace(getJDA().getToken(), "[REDACTED]")); final EmbedBuilder builder = new EmbedBuilder(); if (context != null) builder.setFooter(context, null); final MessageEmbed embed = builder .setColor(error) .setDescription(String.format("%.2048s", message)) .build(); webhook.send(embed) .exceptionally(t -> { log.error("Unable to send error to webhook", t); return null; }); } catch (Exception e) { log.error("Unable to send error to webhook", e); } }
public MessageEmbed getEmbed(Color color, String title, String url, CharSequence description, MessageEmbed.Field... fields) { EmbedBuilder e = new EmbedBuilder(); e.setColor(color); for (MessageEmbed.Field field : fields) { e.addField(field); } e.setTitle(title, url); e.setDescription(description); return e.build(); }
protected void createRaid(User user, GuildMessageReceivedEvent guildEvent, Config config, ClockService clockService, PokemonRaidInfo pokemonRaidInfo, LocalDateTime now, Raid raidToCreate, MessageChannel channel) { Raid createdRaid; if (raidToCreate.isExRaid()) { LOGGER.debug("Got an EX raid to create from gym integration, skipping: " + raidToCreate); return; } createdRaid = raidRepository.newRaid(user, raidToCreate, guildEvent.getGuild(), config, "(bot) !raid new " + raidToCreate.getPokemon().getName() + " " + printTimeIfSameDay(raidToCreate.getEndOfRaid()) + " " + raidToCreate.getGym().getName()); final Locale locale = config.getLocale(); EmbedBuilder embedBuilder = new EmbedBuilder().setTitle(null, null); StringBuilder sb = new StringBuilder(); sb.append(localeService.getMessageFor(LocaleService.NEW_RAID_CREATED, locale, createdRaid.toString(locale))); if (user != null && channel != null) { createGroupIfConfigSaysSo(user, guildEvent, config, clockService, pokemonRaidInfo, now, createdRaid, channel); } else { LOGGER.warn("Could not create group, as some input values were null!"); } embedBuilder.setDescription(sb.toString()); final MessageEmbed messageEmbed = embedBuilder.build(); sendFeedbackThenCleanUp(createdRaid, channel, messageEmbed); }
public static void sendGoLiveMessage(String channelID, MessageEmbed embed, BTBBeamChannel channel) { getJDA().getTextChannelById(channelID).sendMessage(embed).queue(new Consumer<Message>() { @Override public void accept(Message t) { DbManager.createGoLiveMessage(new GoLiveMessage(t.getId(), t.getChannel().getId(), Long.parseLong(t.getGuild().getId()), channel.id)); } }); }
/** * Generic response to failure in restaction * @param throwable Throwable failure * @return MessageEmbed formatted correctly */ public static MessageEmbed handleFailure(Throwable throwable) { EmbedBuilder em = new EmbedBuilder(); em.setTitle("Error", null) .setColor(Color.RED) .setDescription(throwable.getMessage()); return em.build(); }
@Override public void replyMapInChat(Config config, CommandEvent commandEvent, MessageEmbed message) { commandEvent.getChannel().sendMessage(message).queue(m -> { m.delete().queueAfter(BotServerMain.timeToRemoveFeedbackInSeconds * 4, TimeUnit.SECONDS); }); commandEvent.getChannel().deleteMessageById(commandEvent.getMessage().getId()).queueAfter( BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS ); }
public void sendMessageEmbedToAllBoundChannel(MessageEmbed messageEmbed) { List<TextChannel> tcArray = mcb.getRelayChannels(); if (tcArray.size() == 0) { return; } tcArray.forEach((tc) -> tc.sendMessage(messageEmbed).queue()); }
private MessageEmbed.Field getChannelListField(Guild guild) { long total = guild.getTextChannels().size() + guild.getVoiceChannels().size(); StringBuilder memberBuilder = new StringBuilder(); if (!guild.getTextChannels().isEmpty()) { memberBuilder.append(messageService.getMessage("discord.command.server.channels.text", guild.getTextChannels().size())).append("\n"); } if (!guild.getVoiceChannels().isEmpty()) { memberBuilder.append(messageService.getMessage("discord.command.server.channels.voice", guild.getVoiceChannels().size())).append("\n"); } return new MessageEmbed.Field(messageService.getMessage("discord.command.server.channels", total), memberBuilder.toString(), true); }
public void onInstagramUpdated(List<MediaFeedData> medias) { if (latestId != null) { List<MediaFeedData> newMedias = new ArrayList<>(); for (MediaFeedData media : medias) { if (media.getId().equals(latestId)) { break; } newMedias.add(media); } int size = Math.min(MAX_DETAILED, newMedias.size()); if (size > 0) { List<MessageEmbed> embeds = newMedias.stream() .map(e -> convertToEmbed(e).build()) .collect(Collectors.toList()); WebHookMessage message = WebHookMessage.builder() .avatarUrl(discordService.getJda().getSelfUser().getAvatarUrl()) .username(userName) .embeds(embeds) .build(); List<JuniPost> juniPosts = juniPostRepository.findActive(); juniPosts.forEach(e -> discordService.executeWebHook(e.getWebHook(), message, e2 -> { e2.setEnabled(false); webHookRepository.save(e2); })); } } latestId = medias.get(0).getId(); }
@Override public void replyError(Config config, CommandEvent commandEvent, Throwable throwable, LocaleService localeService) { if (config != null && config.getReplyInDmWhenPossible()) { commandEvent.replyInDM(throwable.getMessage()); commandEvent.reactError(); } else { commandEvent.reactError(); EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setAuthor(null, null, null); embedBuilder.setTitle(null); embedBuilder.setDescription(throwable.getMessage()); final MessageEmbed messageEmbed = embedBuilder.build(); commandEvent.reply(messageEmbed); } }
@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); } }
@Override public void reply(Config config, CommandEvent commandEvent, MessageEmbed message) { if (config != null && config.getReplyInDmWhenPossible()) { commandEvent.replyInDM(message); commandEvent.reactSuccess(); handleOriginMessage(commandEvent); } else { replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, message, BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS); } }
public void sendMessageEmbedToAllModChannel(MessageEmbed messageEmbed) { List<TextChannel> tcArray = mcb.getModChannels(); if (tcArray.size() == 0) { return; } tcArray.forEach((tc) -> tc.sendMessage(messageEmbed).queue()); }
private void removeAll(Role role, CommandEvent e, String removedPerms) { mcb.getMcbConfigsManager().getPermConfig().removeKey(role.getId()); configsManager.getPermConfig().saveConfig(); EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setTitle(Locale.getCommandsMessage("perm.sub.remove.success-all").f(role.getName())); embedBuilder.setDescription(Locale.getCommandsMessage("perm.sub.remove.success-all-detail").f(removedPerms)); MessageEmbed formatted = embedMessage(e, embedBuilder.build(), ResponseLevel.LEVEL_1); respond(e, formatted); }
private MessageEmbed generateListEmbed(CommandEvent e) { String path = "textchannel.list."; EmbedBuilder eb = new EmbedBuilder(); eb.setDescription(Locale.getCommandsMessage((path + "header")).finish()); eb.setColor(e.getGuild().getMember(e.getJDA().getSelfUser()).getColor()); java.util.List<TextChannel> tcArray = mcb.getRelayChannels(); tcArray.forEach((tc) -> { String gName = tc.getGuild().getName(); String tcName = tc.getName(); String str = Locale.getCommandsMessage(path + "guild_name").finish() + ": " + gName + "\n"; str += Locale.getCommandsMessage(path + "channel_name").finish() + ": " + tcName; eb.addField("[" + tc + "]" + ": ", str, false); }); return eb.build(); }