本文整理汇总了Java中net.dv8tion.jda.core.entities.Emote类的典型用法代码示例。如果您正苦于以下问题:Java Emote类的具体用法?Java Emote怎么用?Java Emote使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Emote类属于net.dv8tion.jda.core.entities包,在下文中一共展示了Emote类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
}
}
示例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);
}
}
示例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()));
}
}
示例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));
}
示例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));
}
}
示例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));
}
示例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));
}
示例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());
}
}
示例10: consumeEmoteFirst
import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote consumeEmoteFirst() {
return consumeEmote(0);
}
示例11: consumeEmoteLast
import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote consumeEmoteLast() {
return consumeEmote(size() - 1);
}
示例12: consumeEmote
import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote consumeEmote(int index) {
return getEmote(index, true);
}
示例13: getEmoteFirst
import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getEmoteFirst() {
return getEmote(0);
}
示例14: getEmoteLast
import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public final Emote getEmoteLast() {
return getEmote(size() - 1);
}
示例15: AdvancedEmote
import net.dv8tion.jda.core.entities.Emote; //导入依赖的package包/类
public AdvancedEmote(Emote emote) {
this(emote.getName(), null, emote);
}