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


Java EmbedBuilder.setImage方法代码示例

本文整理汇总了Java中net.dv8tion.jda.core.EmbedBuilder.setImage方法的典型用法代码示例。如果您正苦于以下问题:Java EmbedBuilder.setImage方法的具体用法?Java EmbedBuilder.setImage怎么用?Java EmbedBuilder.setImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.dv8tion.jda.core.EmbedBuilder的用法示例。


在下文中一共展示了EmbedBuilder.setImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GameBotCommand

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public GameBotCommand() {
    this.name = "gamebot";
    this.aliases = new String[]{"gb"};
    this.help = "type " + Constant.prefix + "gameBot help";
    this.helpBiConsumer = (CommandEvent event, Command command) -> {
        EmbedBuilder builder = new EmbedBuilder();
        builder.setColor(event.isFromType(ChannelType.TEXT) ? event.getSelfMember().getColor() : Color.GREEN);
        builder.setFooter(event.getSelfUser().getName(), event.getSelfUser().getAvatarUrl());
        builder.setTitle("The \"Game Bot\" Feature");
        builder.setDescription("The \"Game Bot\" feature is quite simple:");
        builder.addField("1.", "If you're playing a game, you just have to go in the server's game channel and react with :ok: in the bot channel", false);
        builder.addField("2.", "After that you'll be moved in a channel with the name of your game", false);
        builder.addField("3.", "If you leave the channel, it will automatically delete the channel", false);
        builder.setImage(Constant.gameBotExampleUrl);
        event.reply(builder.build());
    };
    this.guildOnly = false;
    this.ownerCommand = false;
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:20,代码来源:GameBotCommand.java

示例2: handle

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
    String[] split = event.getMessage().getContent().split(" ");
    String prefix = plugin.getBot().getGuildSettings(event.getGuild()).getSetting("PREFIX");
    if (prefix == null ) {
        prefix = "!";
    }
    String value = split[0].substring(prefix.length()).toLowerCase();
    String result = plugin.getServerCommands(event.getGuild()).get(value);
    if (result != null) {
        if (result.contains(".png") || result.contains(".jpg") || result.contains(".gif")) {
            EmbedBuilder eb = new EmbedBuilder();
            eb.setImage(result);
            eb.setTitle(value);
            eb.build();

            event.getChannel().sendMessage(eb.build()).queue();
        } else {
            event.getChannel().sendMessage(result).queue();
        }
    }
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:23,代码来源:IUnknownCommandHandler.java

示例3: setPhoto

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
private void setPhoto(EmbedBuilder builder, CallbackMessage<CallbackWallPost> message, Photo photo, boolean showText) {
    String url = String.format(PHOTO_URL,
            Math.abs(message.getGroupId()),
            message.getObject().getId(),
            Math.abs(photo.getOwnerId()),
            photo.getId());

    if (showText) {
        setText(builder, photo.getText(), url);
    }
    builder.setImage(coalesce(photo.getPhoto2560(),
            photo.getPhoto1280(),
            photo.getPhoto807(),
            photo.getPhoto604(),
            photo.getPhoto130(),
            photo.getPhoto75()));
    if (photo.getDate() != null) {
        builder.setTimestamp(new Date(((long) photo.getDate()) * 1000).toInstant());
    }
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:21,代码来源:VkServiceImpl.java

示例4: notifyNewYear

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
private void notifyNewYear(NewYearNotification baseNotification, Guild guild) {
    NewYearNotification notification = repository.findOneByGuildId(guild.getId());
    if (notification == null) {
        notification = baseNotification;
    }
    if (notification == null || !notification.isEnabled() || StringUtils.isEmpty(notification.getMessage())) {
        return;
    }
    TextChannel channel = getChannel(notification, guild);
    if (channel == null) {
        return;
    }

    String message = notification.getMessage();
    MapPlaceholderResolver resolver = new MapPlaceholderResolver();
    resolver.put("name", guild.getName());
    message = placeholderHelper.replacePlaceholders(message, resolver);

    EmbedBuilder builder = messageService.getBaseEmbed();
    if (StringUtils.isNotEmpty(notification.getImageUrl())) {
        builder.setImage(notification.getImageUrl());
    }
    builder.setDescription(message);
    messageService.sendMessageSilent(channel::sendMessage, builder.build());
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:26,代码来源:HolidayService.java

示例5: checkUser

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
private void checkUser(CMessage message, String[] args) {
    TextChannel channel = message.getChannel();
    if (args.length != 3) {
        sendUsage(message, "!discord <user> <id|mention>");
        return;
    }
    List<User> mentionedUsers = message.getMentionedUsers();
    User targetUser = null;
    if (mentionedUsers.size() == 0) {
        targetUser = this.charrizard.getDiscordAPI().getUserById(args[2]);
    } else {
        targetUser = mentionedUsers.get(0);
    }
    if (targetUser == null) {
        sendError(message, "This user does not exists!");
        return;
    }
    OffsetDateTime creationTime = targetUser.getCreationTime();
    EmbedBuilder builder = getEmbedBuilder()
                                   .addField("Discord User", targetUser.getName(), true)
                                   .addField("Mention tag", targetUser.getAsMention(), true)
                                   .addField("Register Date", creationTime.getDayOfMonth() + "/" + creationTime.getMonthValue() + "/" + creationTime.getYear() + " " + creationTime.getHour() + ":" + creationTime.getMinute(), true);
    String imageUrl = targetUser.getAvatarUrl();
    if (imageUrl != null && !imageUrl.isEmpty() && !imageUrl.equals("null")) {
        builder.setImage(imageUrl);
    }
    sendEmbedMessage(message, builder);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:29,代码来源:DiscordCommand.java

示例6: checkGuild

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
private void checkGuild(CMessage message, String[] args) {
    TextChannel channel = message.getChannel();
    if (args.length != 3) {
        sendUsage(message, "!discord guild <guild id|this>");
        return;
    }
    String guild = args[2];
    Guild targetGuild = null;
    if (guild.equals("this")) {
        targetGuild = message.getGuild();
    } else {
        targetGuild = this.charrizard.getDiscordAPI().getGuildById(args[2]);
    }
    if (targetGuild == null) {
        sendError(message, "This guild does not exists!");
        return;
    }
    OffsetDateTime creationTime = targetGuild.getCreationTime();
    EmbedBuilder builder = getEmbedBuilder()
                                   .addField("Discord Guild", targetGuild.getName(), true)
                                   .addField("Owner",
                                           "Name: " + targetGuild.getOwner().getUser().getName() +
                                                   "\nMention tag: " + targetGuild.getOwner().getUser().getAsMention() +
                                                   "\nStatus: " + targetGuild.getOwner().getOnlineStatus(), true)
                                   .addField("Statistics: ",
                                           "Users: " + targetGuild.getMembers().size() +
                                                   "\nChannels: " + targetGuild.getTextChannels().size() + targetGuild.getVoiceChannels().size(),
                                           true)
                                   .addField("Register date", creationTime.getDayOfMonth() + "/" + creationTime.getMonthValue() + "/" + creationTime.getYear() + " " + creationTime.getHour() + ":" + creationTime.getMinute(), false);
    String imageUrl = targetGuild.getIconUrl();
    if (imageUrl != null && !imageUrl.isEmpty() && !imageUrl.equals("null")) {
        builder.setImage(imageUrl);
    }
    sendEmbedMessage(message, builder);
}
 
开发者ID:kacperduras,项目名称:Charrizard,代码行数:36,代码来源:DiscordCommand.java

示例7: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    try
    {
        Color color;

        if (event.isFromType(ChannelType.PRIVATE))
            color = Color.decode("#33ff00");
        else
            color = event.getMember().getColor();

        EmbedBuilder builder = new EmbedBuilder();
        OkHttpClient client = new OkHttpClient();
        Request req = new Request.Builder().url("https://random.dog/woof.json").get().build();
        Response res = client.newCall(req).execute();
        if(!res.isSuccessful())
            throw new RuntimeException("Error while fetching remote resource");
        ResponseBody body = res.body();
        String data = body.string();
        JSONObject json = new JSONObject(data);
        String cat = json.getString("url");

        builder.setAuthor("Requested by "+event.getAuthor().getName(), null, event.getAuthor().getEffectiveAvatarUrl());
        builder.setImage(cat);
        builder.setFooter("Image provided by random.dog API", null);
        builder.setColor(color);

        event.reply(builder.build());
    }
    catch(IOException | RuntimeException e)
    {
        event.replyError("An error was thrown when getting the image! Ask the Owner to check the Console.");
        LOG.error(e.getMessage());

        if (config.isDebugEnabled())
            e.printStackTrace();
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:40,代码来源:Dog.java

示例8: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
protected void execute(CommandEvent event)
{
    String args = event.getArgs();

    if(config.getGihpyKey().isEmpty())
    {
        event.replyError("This command has been disabled due a faulty parameter on the config file, ask the Owner to check the Console");
        LOG.warn("Someone triggered the Giphy command, but there isn't a key in the config file. In order to stop this message add a key to the config file.");
        return;
    }

    if(args.isEmpty())
    {
        event.replyWarning("No search terms specified!");
        return;
    }

    Color color;

    if(event.isFromType(ChannelType.PRIVATE))
        color = Color.decode("#33ff00");
    else
        color = event.getMember().getColor();

    SimpleGiphy.setApiKey(config.getGihpyKey());
    RandomGiphyResponse r;
    EmbedBuilder builder = new EmbedBuilder();
    String title = "<:giphy:373675520099090436> Random Giphy Image:";
    r = SimpleGiphy.getInstance().random(args, "pg-13");
    RandomGiphy gif = r.getRandomGiphy();

    builder.setImage(gif.getImageOriginalUrl());
    builder.setFooter("GIF provided by Giphy API", "https://cdn.discordapp.com/attachments/304027425509998593/373674151472267265/Poweredby_640px_Badge.gif");
    builder.setColor(color);

    event.reply(new MessageBuilder().append(title).setEmbed(builder.build()).build());
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:38,代码来源:GiphyGif.java

示例9: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
protected void execute(CommandEvent event)
{
    try
    {
        Color color;

        if(event.isFromType(ChannelType.PRIVATE))
            color = Color.decode("#33ff00");
        else
            color = event.getMember().getColor();

        EmbedBuilder builder = new EmbedBuilder();
        OkHttpClient client = new OkHttpClient();
        Request req = new Request.Builder().url("https://random.cat/meow").get().build();
        Response res = client.newCall(req).execute();
        if(!res.isSuccessful())
            throw new RuntimeException("Error while fetching remote resource");
        ResponseBody body = res.body();
        String data = body.string();
        JSONObject json = new JSONObject(data);
        String cat = json.getString("file");

        builder.setAuthor("Requested by "+event.getAuthor().getName(), null, event.getAuthor().getEffectiveAvatarUrl());
        builder.setImage(cat);
        builder.setFooter("Image provided by random.cat API", null);
        builder.setColor(color);

        event.reply(builder.build());
    }
    catch(IOException | RuntimeException e)
    {
        event.replyError("An error was thrown when getting the image! Ask the Owner to check the Console.");
        LOG.error(e.getMessage());

        if (config.isDebugEnabled())
            e.printStackTrace();
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:39,代码来源:Cat.java

示例10: onUserAvatarUpdate

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
public void onUserAvatarUpdate(UserAvatarUpdateEvent event)
{
    List<Guild> guilds = event.getUser().getMutualGuilds();
    EmbedBuilder builder = new EmbedBuilder();
    User user = event.getUser();
    String title = "`[Avatar Update]:` :frame_photo: **"+user.getName()+"#"+user.getDiscriminator()+"** changed their avatar: ";

    if(!(guilds.isEmpty()) && !(user.isBot()))
    {
        for(Guild guild : guilds)
        {
            TextChannel tc = db.getServerlogChannel(guild);
            TextChannel channel = FinderUtil.getDefaultChannel(guild);

            if(!(tc==null))
            {
                if(!(tc.getGuild().getSelfMember().hasPermission(tc, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_HISTORY)))
                    guild.getOwner().getUser().openPrivateChannel().queue(s -> s.sendMessage(Messages.SRVLOG_NOPERMISSIONS).queue(
                            null, (e) -> channel.sendMessage(Messages.SRVLOG_NOPERMISSIONS).queue()));
                else
                {
                    builder.setAuthor(user.getName(), null, user.getEffectiveAvatarUrl());
                    builder.setThumbnail(event.getPreviousAvatarUrl());
                    builder.setImage(user.getEffectiveAvatarUrl());
                    builder.setColor(guild.getSelfMember().getColor());

                    tc.sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
                }
            }
        }
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:34,代码来源:ServerLogging.java

示例11: execute

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(event.isFromType(ChannelType.TEXT) ? event.getSelfMember().getColor() : Color.GREEN);
    builder.setFooter(event.getSelfUser().getName(), event.getSelfUser().getAvatarUrl());
    builder.setTitle("The \"Game Bot\" Feature");
    builder.setDescription("The \"Game Bot\" feature is quite simple:");
    builder.addField("1.", "If you're playing a game, you just have to go in the server's game channel and react with :ok: in the bot channel", false);
    builder.addField("2.", "After that you'll be moved in a channel with the name of your game", false);
    builder.addField("3.", "If you leave the channel, it will automatically delete the channel", false);
    builder.setImage(Constant.gameBotExampleUrl);
    event.reply(builder.build());
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:14,代码来源:GameBotCommand.java

示例12: embedImage

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:Tisawesomeness,项目名称:Minecord,代码行数:16,代码来源:MessageUtils.java

示例13: genMesg

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public EmbedBuilder genMesg(User user) {
    String level = "", img = "";
    EmbedBuilder embMsg = new EmbedBuilder();
    embMsg.setTitle(user.getName() + "'s stats");
    embMsg.setThumbnail(user.getAvatarUrl());
    embMsg.setColor(new Color(0x13FF00));
    if (numOfMessages < 500) {
        level = "Street Cat";
        img = "https://images.fineartamerica.com/images-medium-large/street-cat-jordi-angrill.jpg";
    } else if (numOfMessages < 2000) {
        level = "Domestic Cat";
        img = "https://img.thrfun.com/img/003/992/cat_on_couch_l4.jpg";
    } else if (numOfMessages < 6000) {
        level = "Money Cat";
        img = "http://68.media.tumblr.com/ccc65aa110ae5c5b9af063ea418183d4/tumblr_nrge8hzV3a1qbxi45o7_r1_1280.jpg";
    } else if (numOfMessages < 12000) {
        level = "Super Cat";
        img = "https://i.ytimg.com/vi/rcMJeTv6P9M/maxresdefault.jpg";
    } else if (numOfMessages < 24000) {
        level = "Cat roll";
        img = "https://i.ytimg.com/vi/tntOCGkgt98/maxresdefault.jpg";
    }
    embMsg.addField("Level", level, true);
    embMsg.addField("Number of messages", String.valueOf(numOfMessages), true);
    embMsg.setImage(img);
    return embMsg;
}
 
开发者ID:ExidCuter,项目名称:JDodoBot,代码行数:28,代码来源:Stats.java

示例14: trigger

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
public boolean trigger(Status status) {
	if(getDiscoChannel() == null || !getDiscoChannel().canTalk()) {
		return false;
	}
	if ((status.isRetweet() && !showRetweets)
			|| (status.getInReplyToScreenName() != null && !showReplies)) {
		return true;
	}
	EmbedBuilder em = new EmbedBuilder();
	String text = status.getText();
	em.setTitle("New tweet from \\@" + status.getUser().getScreenName(),
			"https://twitter.com/" + status.getUser().getScreenName() 
			+ "/status/" + status.getId())
	.setColor(Color.MAGENTA)
	.setThumbnail(status.getUser().getProfileImageURL())
	.setDescription(text);

	String url = null;
	for(MediaEntity e : status.getMediaEntities()) {
		if(this.showPictures && url == null && (e.getType().equals("photo")))
			url = e.getMediaURL();
		text = text.replaceAll(e.getURL(), "");
	}
	if(url != null)
		em.setImage(url);
	if(status.getMediaEntities().length > 0 && url == null || status.getMediaEntities().length > 1) {
		em.setFooter("Tweet contains more media", null);
	} else {
		em.setFooter("Local time", null);
	}
	em.setTimestamp(Instant.now());
	getDiscoChannel().sendMessage(em.build()).queue();
	return true;
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:35,代码来源:TwitterFeedObserver.java

示例15: handle

import net.dv8tion.jda.core.EmbedBuilder; //导入方法依赖的package包/类
@Override
public void handle(Message message, Event event, String[] args) throws Throwable {
    EmbedBuilder normal = kyoko.getAbstractEmbedBuilder().getNormalBuilder();
    Language l = kyoko.getI18n().getLanguage(message.getGuild());
    normal.setTitle(kyoko.getI18n().get(l, "spinner.title"));
    normal.setImage(gifurl);
    message.getTextChannel().sendMessage(normal.build()).queue();
}
 
开发者ID:gabixdev,项目名称:Kyoko,代码行数:9,代码来源:SpinnerCommand.java


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