當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.getMentionedUsers方法代碼示例

本文整理匯總了Java中net.dv8tion.jda.core.entities.Message.getMentionedUsers方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getMentionedUsers方法的具體用法?Java Message.getMentionedUsers怎麽用?Java Message.getMentionedUsers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.dv8tion.jda.core.entities.Message的用法示例。


在下文中一共展示了Message.getMentionedUsers方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: friends

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Command(
        name = "pokemonguess",
        description = "Guess which pokemon it is",
        usage = "`>>pokemonguess`: Play pokemon guess solo\n" +
                "`>>pokemonguess @Someone @SomeoneElse ...`: Play pokemon guess with your friends (if you have any)",
        permission = CommandPermission.USER,
        category = CommandCategory.GAME
)
public static void pokemonguess(@Argument("channel") TextChannel channel, @Argument("author") User author, @Argument("message") Message message) {
    if(check(channel)) return;
    TLongSet players = new TLongHashSet();
    players.add(author.getIdLong());
    for(User u : message.getMentionedUsers()) players.add(u.getIdLong());
    EventManagerThread.current().newThread(()->{
        try {
            Thread.sleep(100);
        } catch(InterruptedException e) {
            return;
        }
        InteractiveOperations.create(channel.getIdLong(), 120, new Pokemon(channel, players));
    }, "Game Starter").start();
}
 
開發者ID:natanbc,項目名稱:GabrielBot,代碼行數:23,代碼來源:GameCommands.java

示例2: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    User author = message.getAuthor();
    try {
        BufferedImage avatar;
        List<User> users = message.getMentionedUsers();
        if (users.isEmpty()) avatar = ReadImage.readImageFromURL(author.getAvatarUrl());
        else avatar = ReadImage.readImageFromURL(users.get(0).getAvatarUrl());
        for (int i = 0; i < gif.length; i++) {
            gif[i] = ReadImage.readImageFromDisk("gif/"+String.valueOf(i)+".png");
        }

        GifImage img = new GifImage(gif[0].getWidth(),gif[0].getHeight(),GifImage.RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE);

        for (int i = 0; i < gif.length; i++) {
            if (i>21) DrawOnImg.drawImg(gif[i],avatar,30-(10*(i-20)),42+(11*(i-20)),110,98);
            else DrawOnImg.drawImg(gif[i],avatar,30,42,110,98);
            img.addGifFrame(new GifFrame(gif[i]));
        }
        img.setDefaultDelay(1);
        GifEncoder.encode(img, new File("hudio.gif"), true);
        Path fileLocation = Paths.get("hudio.gif");
        byte[] data = Files.readAllBytes(fileLocation);

        channel.sendFile(data, "shoot.gif", null).complete();

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:33,代碼來源:Shoot.java

示例3: handle

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的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());

    if (args.length == 1) {
        normal.setTitle(kyoko.getI18n().get(l, "hug.description"));
    } else {
        boolean skipme = false;

        if (message.getRawContent().startsWith(kyoko.getJda().getSelfUser().getAsMention())) {
            if (StringUtil.getOccurencies(message.getRawContent(), kyoko.getJda().getSelfUser().getAsMention()) == 1)
                skipme = true;
        }

        if (message.getMentionedUsers().isEmpty()) {
            //normal.setTitle(kyoko.getI18n().get(l, "hug.description"));
            normal.setTitle(String.format(kyoko.getI18n().get(l, "hug.someone"), args[1], message.getAuthor().getName()));
        } else {
            List<String> userlist = new ArrayList<>();
            for (User u : message.getMentionedUsers()) {
                if (skipme)
                    if (u.getIdLong() == kyoko.getJda().getSelfUser().getIdLong())
                        continue;
                userlist.add(u.getName());
            }
            normal.setTitle(String.format(kyoko.getI18n().get(l, "hug.someone"), String.join(", ", userlist), message.getAuthor().getName()));
        }
    }
    normal.setImage(URLUtil.readUrl(Constants.HUG_URL));

    message.getTextChannel().sendMessage(normal.build()).queue();
}
 
開發者ID:gabixdev,項目名稱:Kyoko,代碼行數:34,代碼來源:HugCommand.java

示例4: execute

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
    Long guildID = author.getGuild().getIdLong();

    if (hasPermission(author)) {
        //if we don't have any parameters, we're resetting to default
        if (parameters.isEmpty()) {
            //check to make sure we're actually changing a default
            channel.sendMessage(localize(channel, "command.set_level_for_user.error.mention_missing")).queue(); //Should I think about breaking this out to make localizion doable?
            //I don't really expect this bot to get popular but this might make the bot popular thing along non-english servers..
        } else {
            parameters = parameters.trim();
            Integer levelID = null;
            for (String para : parameters.split(" ")) {
                if (isInteger(para)) {
                    levelID = Integer.valueOf(para);
                }
            }
            if (levelID != null && levelID > 1) {
                List<User> mentionedUsers = message.getMentionedUsers();
                if (hasPermission(author, levelID - 1)) {

                    if (!mentionedUsers.isEmpty()) {
                        for (User user : mentionedUsers) {
                            try {
                                String userLevelName = dbMan.getLevelName(guildID, levelID);
                                dbMan.setUserLevel(guildID, levelID, user.getIdLong());
                                channel.sendMessage(localize(channel, "command.set_level_for_user.success", userLevelName, user.getAsMention())).queue();
                            } catch (SQLException e) {
                                e.printStackTrace();
                                channel.sendMessage(localize(channel, "command.set_level_for_user.error.sql")).queue();
                            }
                        }
                    }
                } else {
                    channel.sendMessage(localize(channel, "command.set_level_for_user.error.insufficient_permission_level")).queue();
                }

            } else if (levelID != null && levelID < 2) {
                channel.sendMessage(localize(channel, "command.set_level_for_user.error.special_level", dbMan.getLevelName(guildID, levelID))).queue();
            } else {
                channel.sendMessage(localize(channel, "command.set_level_for_user.error.unknown_level")).queue();
            }
        }
    }

}
 
開發者ID:IANetworks,項目名稱:Ducky-Mc-Duckerson,代碼行數:48,代碼來源:SetPermissionByUserCS.java

示例5: onCommand

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public boolean onCommand(Message message, String[] args) {
    int toDelete = 100;
    if (args.length > 0) {
        toDelete = NumberUtil.getBetween(NumberUtil.parseInt(args[0]), 1, 100);
    }

    message.getChannel().sendTyping().queue();
    if (message.getMentionedUsers().isEmpty()) {
        loadMessages(message.getChannel().getHistory(), toDelete, new ArrayList<>(), null, 1, messages -> {
            if (messages.isEmpty()) {
                sendNoMessagesMessage(message);
                return;
            }

            deleteMessages(message, messages).queue(aVoid ->
                MessageFactory.makeSuccess(message, ":white_check_mark: `:number` messages has been deleted!")
                    .set("number", messages.size())
                    .queue(successMessage -> successMessage.delete().queueAfter(8, TimeUnit.SECONDS)));
        });
        return true;
    }

    List<Long> userIds = new ArrayList<>();
    for (User user : message.getMentionedUsers()) {
        userIds.add(user.getIdLong());
    }

    loadMessages(message.getChannel().getHistory(), toDelete, new ArrayList<>(), userIds, 1, messages -> {
        if (messages.isEmpty()) {
            sendNoMessagesMessage(message);
            return;
        }

        deleteMessages(message, messages).queue(aVoid -> {
            List<String> users = new ArrayList<>();
            for (Long userId : userIds) {
                users.add(String.format("<@%s>", userId));
            }

            MessageFactory.makeSuccess(message, ":white_check_mark: `:number` messages has been deleted from :users")
                .set("number", messages.size())
                .set("users", String.join(", ", users))
                .queue(successMessage -> successMessage.delete().queueAfter(8, TimeUnit.SECONDS));
        });
    });
    return true;
}
 
開發者ID:avaire,項目名稱:avaire,代碼行數:49,代碼來源:PurgeCommand.java


注:本文中的net.dv8tion.jda.core.entities.Message.getMentionedUsers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。