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

Java Emote类代码示例

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

本文整理汇总了Java中net.dv8tion.jda.core.entities.Emote的典型用法代码示例。如果您正苦于以下问题:Java Emote类的具体用法?Java Emote怎么用?Java Emote使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: verifyEmoji

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
/**
 * verify that a supplied emoji string is a valid discord emoji
 * @param emoji emoji string (either raw emoji char or discord emoji ID)
 * @return true if valid
 */
public static boolean verifyEmoji(String emoji)
{
    if(!EmojiManager.isEmoji(emoji))
    {
        String emoteId = emoji.replaceAll("[^\\d]", "");
        Emote emote = null;
        try
        {
            for(JDA jda : Main.getShardManager().getShards())
            {
                emote = jda.getEmoteById(emoteId);
                if(emote != null) break;
            }
        }
        catch(Exception e)
        {
            return false;
        }
        if(emote == null)
        {
            return false;
        }
    }
    return true;
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:31,代码来源:VerifyUtilities.java


示例2: addRSVPReaction

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
/**
 * helper to addRSVPReactions(..)
 * @param emoji string emoticon, or emote ID
 * @param message message object to react to
 */
private static void addRSVPReaction(String emoji, Message message)
{
    if(EmojiManager.isEmoji(emoji))
    {
        message.addReaction(emoji).queue();
    }
    else
    {
        Emote emote;
        for(JDA shard : Main.getShardManager().getShards())
        {
            emote = shard.getEmoteById(emoji);
            if(emote != null)
            {
                message.addReaction(emote).queue();
                break;
            }
        }
    }
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:26,代码来源:EntryManager.java


示例3: execute

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
@Override
protected void execute(String args, MessageReceivedEvent event) {
    String id = args.replaceAll("<:.+:(\\d+)>", "$1");
    Emote emote = event.getJDA().getEmoteById(id);
    if(emote==null)
        tempReply("Invalid emote or emote ID", event);
    else
    {
        EmbedBuilder builder = new EmbedBuilder();
        if(event.getGuild()!=null)
            builder.setColor(event.getGuild().getSelfMember().getColor());
        builder.setImage(emote.getImageUrl());
        builder.setDescription(emote.getAsMention()+" **:"+emote.getName()+":**\nID: **"+emote.getId()+"**\nGuild: **"+emote.getGuild().getName()+"**");
        reply(builder.build(), event);
    }
}
 
开发者ID:jagrosh,项目名称:Selfbot,代码行数:17,代码来源:EmoteCmd.java


示例4: handleReplace

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
private void handleReplace(Emote oldEmote, Emote newEmote)
{
    if (oldEmote == null || newEmote == null) return;

    if (!Objects.equals(oldEmote.getName(), newEmote.getName()))
    {
        api.getEventManager().handle(
            new EmoteUpdateNameEvent(
                api, responseNumber,
                newEmote, oldEmote.getName()));
    }

    if (!CollectionUtils.isEqualCollection(oldEmote.getRoles(), newEmote.getRoles()))
    {
        api.getEventManager().handle(
            new EmoteUpdateRolesEvent(
                api, responseNumber,
                newEmote, oldEmote.getRoles()));
    }

}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:22,代码来源:GuildEmojisUpdateHandler.java


示例5: getEmote

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getEmote(int index, boolean consume) {
    if (guild == null) {
        return null;
    }
    final String temp = getRaw(index);
    if (temp == null) {
        return null;
    }
    final Matcher matcher = PATTERN_MARKDOWN_CUSTOM_EMOJI.matcher(temp);
    if (!matcher.matches()) {
        return null;
    }
    if (consume) {
        consumeRaw(index);
    }
    return guild.getEmoteById(matcher.group(1));
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:18,代码来源:ArgumentList.java


示例6: parse

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public static final AdvancedEmote parse(Guild guild, String text) {
    final Matcher matcher = ArgumentList.PATTERN_MARKDOWN_CUSTOM_EMOJI.matcher(text);
    if (guild == null && !matcher.matches()) {
        return parse(text);
    } else if (guild != null) {
        Emote emote = guild.getEmoteById(text);
        if (emote == null) {
            emote = guild.getEmotesByName(text, false).stream().findFirst().orElse(null);
        }
        return new AdvancedEmote(emote != null ? emote.getName() : text, null, emote);
    } else {
        final String id = matcher.group(2);
        return new AdvancedEmote(matcher.group(1), null, Standard.getGuilds().stream().filter((advancedGuild) -> advancedGuild.getGuild() != null).map((advancedGuild) -> advancedGuild.getGuild().getEmoteById(id)).filter((emote) -> emote != null).findFirst().orElse(null));
    }
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:16,代码来源:AdvancedEmote.java


示例7: getGuildReactionOnMention

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getGuildReactionOnMention(Guild guild) {
    final String reaction_on_mention = getValue(guild.getIdLong(), 0, KEY_GUILD_REACTION_ON_MENTION, null);
    if (reaction_on_mention == null) {
        return null;
    }
    final Matcher matcher = ArgumentList.PATTERN_MARKDOWN_CUSTOM_EMOJI.matcher(reaction_on_mention);
    if (!matcher.matches()) {
        return null;
    }
    return guild.getEmoteById(matcher.group(2));
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:12,代码来源:Config.java


示例8: getGuildReactionOnCommandNotFound

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getGuildReactionOnCommandNotFound(Guild guild) {
    final String reaction_on_command_not_found = getValue(guild.getIdLong(), 0, KEY_GUILD_REACTION_ON_COMMAND_NOT_FOUND, () -> Emoji.QUESTION_MARK);
    if (reaction_on_command_not_found == null) {
        return null;
    }
    final Matcher matcher = ArgumentList.PATTERN_MARKDOWN_CUSTOM_EMOJI.matcher(reaction_on_command_not_found);
    if (!matcher.matches()) {
        return null;
    }
    return guild.getEmoteById(matcher.group(2));
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:12,代码来源:Config.java


示例9: execute

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
@Override
protected void execute(CommandEvent event) {
    final List<Emote> currentEmotes = event.getGuild().getEmotes();
    final Set<String> emoteNamesToInstall = new HashSet<>(Arrays.asList("mystic", "valor", "instinct"));
    boolean emotesAlreadyInstalled = false;
    for (Emote emote : currentEmotes) {
        final String emoteToInstall = emote.getName().toLowerCase();
        if (emoteNamesToInstall.contains(emoteToInstall)) {
            event.reply(localeService.getMessageFor(LocaleService.EMOTE_INSTALLED_ALREADY,
                    localeService.getLocaleForUser(event.getAuthor()), emoteToInstall));
            emotesAlreadyInstalled = true;
        }
    }

    if (emotesAlreadyInstalled) {
        return;
    }

    final InputStream mysticPngResource =
            InstallEmotesCommand.class.getResourceAsStream("/static/img/mystic.png");
    final InputStream valorPngResource =
            InstallEmotesCommand.class.getResourceAsStream("/static/img/valor.png");
    final InputStream instinctPngResource =
            InstallEmotesCommand.class.getResourceAsStream("/static/img/instinct.png");
    try {
        event.reply("Installing icons for Pokemon go teams...");
        createEmote("mystic", event, Icon.from(mysticPngResource));
        createEmote("valor", event, Icon.from(valorPngResource));
        createEmote("instinct", event, Icon.from(instinctPngResource));
        event.reply("Emotes installed. Try them out: :mystic: :valor: :instinct:");
    } catch (Throwable t) {
        event.reply(t.getMessage());
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:35,代码来源:InstallEmotesCommand.java


示例10: consumeEmoteFirst

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote consumeEmoteFirst() {
    return consumeEmote(0);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:ArgumentList.java


示例11: consumeEmoteLast

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote consumeEmoteLast() {
    return consumeEmote(size() - 1);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:ArgumentList.java


示例12: consumeEmote

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote consumeEmote(int index) {
    return getEmote(index, true);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:ArgumentList.java


示例13: getEmoteFirst

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getEmoteFirst() {
    return getEmote(0);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:ArgumentList.java


示例14: getEmoteLast

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getEmoteLast() {
    return getEmote(size() - 1);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:ArgumentList.java


示例15: AdvancedEmote

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public AdvancedEmote(Emote emote) {
    this(emote.getName(), null, emote);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:AdvancedEmote.java


示例16: getEmote

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getEmote() {
    return emote;
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:AdvancedEmote.java


示例17: parseEmote

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public static final Emote parseEmote(Guild guild, String emote_id) {
    return guild.getEmoteById(emote_id);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:4,代码来源:Standard.java


示例18: onMessage

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
private final void onMessage(final Object event_original, final MessageEvent event, boolean newMessage) {
    Updater.submit(() -> {
        try {
            final String content_raw = event.getMessage().getRawContent().trim();
            final String content = event.getMessage().getContent().trim();
            final Guild guild = event.getGuild();
            final CommandType commandType = CommandType.getCommandType(content, content_raw, event);
            if (commandType.isCommand()) {
                CommandHandler.handleCommand(CommandParser.parser(commandType, content, content_raw, event));
            } else if (content_raw.contains(Standard.getSelfUser().getAsMention()) || content_raw.contains(Standard.getSelfMemberByGuild(guild).getAsMention())) {
                final Emote reaction_emote = Config.CONFIG.getGuildReactionOnMention(guild);
                if (reaction_emote != null) {
                    event.getMessage().addReaction(reaction_emote).queue();
                } else {
                    final Emoji reaction_emoji = Config.CONFIG.getGuildReactionOnMention(guild.getIdLong());
                    if (reaction_emoji != null) {
                        event.getMessage().addReaction(reaction_emoji.getUnicode()).queue();
                    }
                }
            }
            final Object[] output = ListenerManager.fireListeners(MessageListener.class, CommandHandler.ADMIN_PREDICATE, new Object[]{newMessage ? event : event_original, newMessage ? MessageType.RECEIVED : MessageType.UPDATED});
            String embed_messages = event.getMessage().getEmbeds().stream().map((messageEmbed) -> Util.embedMessageToString(messageEmbed)).collect(Collectors.joining(Standard.NEW_LINE_DISCORD));
            if (!embed_messages.isEmpty()) {
                embed_messages = Standard.NEW_LINE_DISCORD + embed_messages;
            }
            final List<Attachment> attachments = event.getMessage().getAttachments();
            if (attachments == null || attachments.isEmpty()) {
                System.out.println(String.format("[Used %d time%s] [%s] [%s] %s: %s%s", output.length, (output.length == 1 ? "" : "s"), (guild != null ? guild.getName() : "PRIVATE"), event.getMessageChannel().getName(), Standard.getCompleteName(event.getAuthor(), true), content, embed_messages));
            } else {
                String text = "";
                for (Attachment attachment : attachments) {
                    text += Standard.NEW_LINE_DISCORD;
                    if (attachment.isImage()) {
                        text += String.format("IMAGE: \"%s\" (ID: %s) (PROXYURL: %s) (W: %d, H: %d)", attachment.getFileName(), attachment.getId(), attachment.getProxyUrl(), attachment.getWidth(), attachment.getHeight());
                    } else {
                        text += String.format("FILE: \"%s\" (ID: %s) (URL: %s)", attachment.getFileName(), attachment.getId(), attachment.getUrl());
                    }
                }
                System.out.println(String.format("[Used %d time%s] [%s] [%s] %s: %s%s%s", output.length, (output.length == 1 ? "" : "s"), event.getGuild().getName(), event.getMessageChannel().getName(), Standard.getCompleteName(event.getAuthor(), true), content, text, embed_messages));
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    });
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:46,代码来源:MessageHandler.java


示例19: createEmote

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
private void createEmote(String iconName, CommandEvent commandEvent, Icon icon, Role... roles) {
    JSONObject body = new JSONObject();
    body.put("name", iconName);
    body.put("image", icon.getEncoding());
    if (roles.length > 0) // making sure none of the provided roles are null before mapping them to the snowflake id
    {
        body.put("roles",
                Stream.of(roles).filter(Objects::nonNull).map(ISnowflake::getId).collect(Collectors.toSet()));
    }

    // todo: check bot permissions, must be able to handle emojis
    GuildImpl guild = (GuildImpl) commandEvent.getGuild();
    JDA jda = commandEvent.getJDA();
    Route.CompiledRoute route = Route.Emotes.CREATE_EMOTE.compile(guild.getId());
    AuditableRestAction<Emote> action = new AuditableRestAction<Emote>(jda, route, body)
    {
        @Override
        protected void handleResponse(Response response, Request<Emote> request)
        {
            if (response.isOk()) {
                JSONObject obj = response.getObject();
                final long id = obj.getLong("id");
                String name = obj.getString("name");
                EmoteImpl emote = new EmoteImpl(id, guild).setName(name);
                // managed is false by default, should always be false for emotes created by client accounts.

                JSONArray rolesArr = obj.getJSONArray("roles");
                Set<Role> roleSet = emote.getRoleSet();
                for (int i = 0; i < rolesArr.length(); i++)
                {
                    roleSet.add(guild.getRoleById(rolesArr.getString(i)));
                }

                // put emote into cache
                guild.getEmoteMap().put(id, emote);

                request.onSuccess(emote);
            }
            else {
                request.onFailure(response);
                throw new RuntimeException("Couldn't install emojis. " +
                        "Make sure that pokeraidbot has access to manage emojis.");
            }
        }
    };
    action.queue();
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:48,代码来源:InstallEmotesCommand.java


示例20: exec

import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
@Override
public void exec(String[] args, String rawArgs, MessageReceivedEvent e, GuildPreferences guildPreferences) {
	EmbedBuilder eb = new EmbedBuilder();
	eb.setColor(Globals.EMBED_COLOR_PRIMARY);
	eb.setAuthor("Mac's Grimoire: An MTG Discord Bot", Grimoire.WEBSITE, e.getJDA().getSelfUser().getAvatarUrl());

	eb.appendDescription("**Mac's Grimoire** is a Discord bot that brings many **Magic The Gathering** related tools straight into your discord server. ");
	eb.appendDescription("I can perform tasks like card-, price- or rule lookups, and more!");

	if (e.getGuild() != null)
		eb.appendDescription("\n\n:large_blue_diamond: The current command prefix for guild **'" + e.getGuild().getName() + "'** is set to `" + guildPreferences.getPrefix() + "`.");

	eb.appendDescription("\n\n**Type any of the following options to get more info:**");

	eb.addField("commands", "List all available commands", false);

	eb.addField("help <command>", "Get help with a specific command", false);

	eb.addField("inline references", "Explain inline references", false);

	StringBuilder sb = new StringBuilder();

	sb.append("\n:white_check_mark: [Invite me!](" + Grimoire.WEBSITE + "/invite)");
	sb.append("\n:earth_africa: [Website](" + Grimoire.WEBSITE + ")");
	sb.append("\n:wrench:  [Preference Dashboard](" + Grimoire.WEBSITE + "/dashboard)");

	eb.addField("", sb.toString(), true);
	sb.delete(0, sb.length());

	sb.append("\n:link: [Command Reference](" + Grimoire.WEBSITE + "/reference)");
	sb.append("\n:speech_balloon: [Support Server](" + Grimoire.WEBSITE + "/support)");
	sb.append("\n:heart: [Donate](https://paypal.me/BeMacized)");

	eb.addField("", sb.toString(), true);
	sb.delete(0, sb.length());

	Guild dbotsorgGuild = e.getJDA().getGuildById(264445053596991498L);
	Emote dbotsorgEmote = dbotsorgGuild == null ? null : dbotsorgGuild.getEmotesByName("discordbot", true).stream().findFirst().orElse(null);
	sb.append("\n:gear: [Source Code](https://github.com/BeMacized/Grimoire)");
	sb.append("\n" + (dbotsorgEmote == null ? ":link:" : dbotsorgEmote.getAsMention()) + " [DiscordBots.org Page](https://discordbots.org/bot/239399098862665728)");

	eb.addField("", sb.toString(), true);
	sb.delete(0, sb.length());

	eb.addField(":globe_with_meridians: Server Count", "**" + e.getJDA().getGuilds().size() + "** Server" + (e.getJDA().getGuilds().size() > 1 ? "s" : ""), true);
	long users = e.getJDA().getGuilds().parallelStream().map(g -> g.getMembers().parallelStream()).flatMap(o -> o).map(m -> m.getUser().getId()).distinct().count();
	eb.addField(":busts_in_silhouette: Total Users", "**" + users + "** User" + (users > 1 ? "s" : ""), true);
	eb.addField(":gear: Discord Library", "JDA", true);

	if (e.getGuild() != null)
		sendEmbed(e.getChannel(), "I've sent you help in a private message!");
	try {
		e.getAuthor().openPrivateChannel().submit().get().sendMessage(eb.build()).submit();
	} catch (InterruptedException | ExecutionException ex) {
		LOG.log(Level.SEVERE, "Could not send help", ex);
	}
}
 
开发者ID:BeMacized,项目名称:Grimoire,代码行数:58,代码来源:HelpCommand.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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