当前位置: 首页>>代码示例>>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;未经允许,请勿转载。