Java 类net.dv8tion.jda.core.entities.Message 实例源码

项目:Saber-Bot    文件:AvatarCommand.java   
@Override
public void action(String head, String[] args, MessageReceivedEvent event)
{
    AccountManagerUpdatable manager = Main.getShardManager().getJDA().getSelfUser().getManagerUpdatable();
    if(event.getMessage().getAttachments().isEmpty()) return;

    Message.Attachment attachment = event.getMessage().getAttachments().get(0);
    try
    {
        File file = new File(attachment.getFileName());
        attachment.download(file);

        Icon icon = Icon.from(file);
        manager.getAvatarField().setValue(icon).update().complete();

        MessageUtilities.sendPrivateMsg("Updated bot avatar!", event.getAuthor(), null);
        file.delete();
    }
    catch (IOException e)
    {
        Logging.exception(this.getClass(), e);
        MessageUtilities.sendPrivateMsg("Failed to update bot avatar!", event.getAuthor(), null);
    }

}
项目:Minecord    文件:Bot.java   
@SuppressWarnings("static-access")
public static void shutdown(Message m, User u) {

    //Disable JDA
    for (JDA jda : shards) {
        jda.setAutoReconnect(false);
        jda.removeEventListener(listener);
    }
    try {
        //Reload this class using reflection
        Class<?> main = Thread.currentThread().getContextClassLoader().getSystemClassLoader()
            .loadClass(mainClass);
        String[] args = new String[]{"-r"};
        ArrayUtils.addAll(args, Bot.args);
        main.getDeclaredMethods()[MethodName.SET_MESSAGE.num].invoke(null, m);
        main.getDeclaredMethods()[MethodName.SET_USER.num].invoke(null, u);
        main.getDeclaredMethods()[MethodName.LOAD.num].invoke(null, (Object) args);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    //Stop the thread
    thread.interrupt();

}
项目:SafetyJim    文件:Invite.java   
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
    Message message = event.getMessage();
    TextChannel channel = event.getChannel();
    JDA shard = event.getJDA();

    if (!embedHasAvatarURL) {
        embedBuilder.setAuthor("Safety Jim", null, shard.getSelfUser().getAvatarUrl());
        embed = embedBuilder.build();
        embedHasAvatarURL = true;
    }

    DiscordUtils.successReact(bot, message);
    DiscordUtils.sendMessage(channel, embed);

    return false;
}
项目:Ducky-Mc-Duckerson    文件:DeleteCommandCS.java   
@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)) {
        //toggle command
        Boolean delCmd = !dbMan.getDeleteCommand(guildID);
        try {
            dbMan.setDeleteCommand(guildID, delCmd);
            if (!delCmd) {
                message.addReaction(":heavy_check_mark:").queue();
            }
        } catch (SQLException e) {
            channel.sendMessage(localize(channel, "command.toggle_delete.error.sql")).queue();
        }


    }

}
项目:avaire    文件:ChangePrefixCommand.java   
private boolean removeCustomPrefix(Message message, GuildTransformer transformer, Category category) {
    transformer.getPrefixes().remove(category.getName().toLowerCase());

    try {
        updateGuildPrefixes(message, transformer);
        MessageFactory.makeSuccess(message, "All commands in the `:category` command category has been reset to use the `:prefix` prefix.")
            .set("category", category.getName())
            .set("prefix", category.getPrefix())
            .queue();

        return true;
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return false;
}
项目:avaire    文件:AutoAssignRoleCommand.java   
private PlaceholderMessage sendCurrentAutoRole(Message message, GuildTransformer transformer) {
    if (transformer.getAutorole() == null) {
        return MessageFactory.makeWarning(message, ":user **Auto assign role** on user join is currently **disabled**.");
    }

    Role role = message.getGuild().getRoleById(transformer.getAutorole());
    if (role == null) {
        try {
            updateAutorole(transformer, message, null);
        } catch (SQLException ex) {
            ex.printStackTrace();
            AvaIre.getLogger().error(ex.getMessage(), ex);
        }
        return MessageFactory.makeWarning(message, ":user **Auto assign role** on user join is currently **disabled**.");
    }

    return MessageFactory.makeSuccess(message, ":user The **auto assign role** is currently set to **:role**")
        .set("role", role.getName());
}
项目:GameResourceBot    文件:Commands.java   
private static void groupRemove(Scanner scanner, Message message) {
    Optional<StockTypeGroup> groupOpt = getTargetGroup(scanner, message, "REMOVE");
    if (groupOpt.isPresent()) {
        List<StockType> stockTypes = getTargetStockTypes(scanner, message, "REMOVE");
        StockTypeGroup group = groupOpt.get();
        if (!stockTypes.isEmpty()) {
            List<StockType> types = group.getTypes();
            if (types == null) {
                group.setTypes(new ArrayList<>());
            }
            group.getTypes().removeAll(stockTypes);
            getStockTypeGroupDao().update(group);
            message.addReaction(Speaker.Reaction.SUCCESS).queue();
        }
    }
}
项目:JDodoBot    文件:Reddit.java   
@Override
public void doYaThing(Message message) {
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    try {
        if (commandNParameters.length > 1) {
            for (Submission s : RedditHandler.getPosts(commandNParameters[1], 2)) {
                channel.sendMessage("https://www.reddit.com" + s.getPermalink()).complete();
            }
        } else
            channel.sendMessage("```" + prefix + usage + "```").complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        channel.sendMessage("```" + e.getMessage() + "```").complete();
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:Kyoko    文件:SayCommand.java   
@Override
public void handle(Message message, Event event, String[] args) throws Throwable {
    if (args.length == 1) {
        printUsage(kyoko, kyoko.getI18n().getLanguage(message.getGuild()), message.getTextChannel());
        return;
    }

    String msg = message.getRawContent();
    String mention = kyoko.getJda().getSelfUser().getAsMention();
    if (msg.startsWith(mention)) {
        msg = msg.substring(mention.length()).trim().substring(args[0].length());
    } else {
        msg = msg.substring(kyoko.getSettings().getPrefix().length() + args[0].length());
    }

    if (msg.trim().isEmpty()) {
        printUsage(kyoko, kyoko.getI18n().getLanguage(message.getGuild()), message.getTextChannel());
        return;
    }

    message.getTextChannel().sendMessage(msg).queue();
}
项目:Rubicon    文件:CommandQRCode.java   
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    String[] args = parsedCommandInvocation.getArgs();
    Message message = parsedCommandInvocation.getMessage();
    Message mymsg = message.getTextChannel().sendMessage(EmbedUtil.info("Generating", "Generating QR cde").build()).complete();
    if(args.length > 0){
        StringBuilder text = new StringBuilder();
        for(int i = 0; i < args.length; i++){
            text.append(args[i]).append(" ");
        }
        try {
            InputStream code = new URL("https://api.qrserver.com/v1/create-qr-code/?data=" + text.toString().replace(" ", "+") + "&size=220x220&margin=0").openStream();
            mymsg.delete().queue();
            message.getTextChannel().sendFile(code, "qrcode.png", null).queue();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "qr <text>").build()).build();
    }
    return null;
}
项目:avaire    文件:PauseCommand.java   
@Override
public boolean onCommand(Message message, String[] args) {
    GuildMusicManager musicManager = AudioHandler.getGuildAudioPlayer(message.getGuild());

    if (musicManager.getPlayer().getPlayingTrack() == null) {
        return sendErrorMessage(message, "Nothing to pause, request music first with `!play`");
    }

    if (musicManager.getPlayer().isPaused()) {
        MessageFactory.makeWarning(message, "The music is already paused, use `!resume` to resume the music.").queue();
        return true;
    }

    musicManager.getPlayer().setPaused(true);
    MessageFactory.makeSuccess(message, "The music has been `paused`").queue();

    return true;
}
项目:avaire    文件:HasRole.java   
@Override
public boolean handle(Message message, MiddlewareStack stack, String... args) {
    if (!message.getChannelType().isGuild()) {
        return stack.next();
    }

    if (message.getMember().hasPermission(Permissions.ADMINISTRATOR.getPermission())) {
        return stack.next();
    }

    List<Role> roles = message.getMember().getRoles();
    for (String roleName : args) {
        if (!hasRole(roles, roleName)) {
            MessageFactory.makeError(message, "You don't have the required role to execute this command:\n`:role`")
                .set("role", roleName)
                .queue();
            return false;
        }
    }

    return stack.next();
}
项目:avaire    文件:IPInfoCommand.java   
@Override
public boolean onCommand(Message message, String[] args) {
    if (args.length == 0) {
        return sendErrorMessage(message, "Missing argument `ip`, you must include a valid IP address.");
    }

    if (!urlRegEX.matcher(args[0]).find()) {
        return sendErrorMessage(message, "Invalid IP address given, you must parse a valid IP address.");
    }

    RequestFactory.makeGET("http://ipinfo.io/" + args[0] + "/json").send((Consumer<Response>) response -> {
        JSONObject json = new JSONObject(response.toString());

        MessageFactory.makeEmbeddedMessage(message.getChannel(), Color.decode("#005A8C"),
            new MessageEmbed.Field("Hostname", json.has("hostname") ? json.getString("hostname") : "Unknown", true),
            new MessageEmbed.Field("Organisation", json.has("org") ? json.getString("org") : "Unknown", true),
            new MessageEmbed.Field("Country", generateLocation(json), false)
        ).setTitle(args[0]).setFooter(generateFooter(message), null).queue();
    });

    return true;
}
项目:Supreme-Bot    文件:ReactionListener.java   
public static boolean unregisterListener(Message message, boolean removeReactions) {
    if (message == null) {
        return false;
    }
    final Map<AdvancedEmote, ReactionContainer> containers = MESSAGE_REACTION_LISTENERS.get(message);
    if (containers == null) {
        return true;
    }
    MESSAGE_REACTION_LISTENERS.remove(message);
    if (removeReactions) {
        try {
            Standard.getUpdatedMessage(message).queue((message_) -> message_.clearReactions().queue());
        } catch (Exception ex) {
            System.err.println("ReactionListener unregisterListener2 error: " + ex);
        }
    }
    return true;
}
项目:TransparentDiscord    文件:UITextChat.java   
@Override
public void receiveMessage(Message message) {
    if (newestGroup.canAddMessage(message))
        newestGroup.addMessage(message);
    else {
        newestGroup = new UIMessageGroup(message);
        messageList.add(newestGroup, c, messageList.getComponentCount()); //Add the received message at the bottom of the message list
    }

    refresh();
    scrollToBottom();
}
项目:TransparentDiscord    文件:UIGroupChat.java   
@Override
public void receiveMessage(Message message) {
    if (newestGroup.canAddMessage(message))
        newestGroup.addMessage(message);
    else {
        newestGroup = new UIMessageGroup(message);
        messageList.add(newestGroup, c, messageList.getComponentCount()); //Add the received message at the bottom of the message list
    }

    refresh();
    scrollToBottom();
}
项目:avaire    文件:PlayCommand.java   
private void sendTrackResponse(Message message, TrackResponse response) {
    AudioTrack track = (AudioTrack) response.getAudioItem();

    MessageFactory.makeSuccess(message,
        ":user has added [:title](:url) to the queue. There are `:queueSize` song(s) ahead of it in the queue."
    )
        .set("title", track.getInfo().title)
        .set("url", track.getInfo().uri)
        .set("queueSize", AudioHandler.getQueueSize(response.getMusicManager()))
        .queue();
}
项目:GameResourceBot    文件:Commands.java   
private static void checkPublic(Message message) {
    if (!ChannelType.TEXT.equals(message.getChannelType())) {
        message.addReaction(Speaker.Reaction.FAILURE).queue();
        Speaker.say(message.getChannel(),
                Resource.getString("PUBLIC_COMMAND_ONLY", getResponseLocale(message)));
        throw new IllegalStateException("public command only");
        // TODO MORE SOLID IMPLEMENTATION
    }
}
项目:Minecord    文件:ReloadCommand.java   
public Result run(String[] args, MessageReceivedEvent e) {

    //Check for dev mode
    if (!Config.getDevMode()) {
        return new Result(Outcome.ERROR, "You can only reload code in dev mode!");
    }

    //Shut down bot
    Message m = e.getChannel().sendMessage(":arrows_counterclockwise: Reloading...").complete();
    Bot.shutdown(m, e.getAuthor());

    return new Result(Outcome.SUCCESS);
}
项目:momo-2    文件:Radio.java   
@Override
public void executeCommand(Message msg) {
    Optional<VoiceChannel> opt;
    GuildObject g = GuildObject.guildMap.get(msg.getGuild().getId());
    net.dv8tion.jda.core.managers.AudioManager audio = msg.getGuild().getAudioManager();
    boolean djSet = !g.getConfig().getDjRoleId().isEmpty();
    if ((djSet && !msg.getGuild().getMember(msg.getAuthor())
            .getRoles().contains(msg.getGuild().getRoleById(g.getConfig().getDjRoleId())))
            && !Util.memberHasPermission(msg.getGuild().getMember(msg.getAuthor()), Permission.KICK)) {
        // Opting to fail silently here
        return;
    }
    EmbedBuilder em = new EmbedBuilder();
    // First, check if the guild has a designated music channel
    if (!g.getSpecialChannels().getMusicVoice().isEmpty() 
            && msg.getJDA().getVoiceChannelById(g.getSpecialChannels().getMusicVoice()) != null) {
        audio.openAudioConnection(msg.getJDA().getVoiceChannelById(g.getSpecialChannels().getMusicVoice()));
    } else if (!audio.isConnected() && !audio.isAttemptingToConnect()) {
        if ((opt = msg.getGuild().getVoiceChannels().stream()
                .filter(v -> v.getMembers().contains(msg.getGuild().getMember(msg.getAuthor())))
                .findAny()).isPresent()) {
            // User is in a channel, calling the play method
            audio.openAudioConnection(opt.get());
        } else {
            // User isn't in a channel, yell at them
            em.setTitle("Error", null)
            .setColor(Color.RED)
            .setDescription("You must be in a voice channel so I know where to go!");
            msg.getChannel().sendMessage(em.build()).queue();
            return;
        }
    }
    // At this point, we're connected to a voice channel

    GuildMusicManager.loadAndPlay(msg.getTextChannel(), 
            URL, "r/a/dio", msg.getGuild().getMember(msg.getAuthor()), true);
}
项目:avaire    文件:FeedbackCommand.java   
@Override
public boolean onCommand(Message message, String[] args) {
    if (args.length == 0) {
        return sendErrorMessage(message, "Missing argument `message`, you must include a message.");
    }

    TextChannel feedbackChannel = avaire.getTextChannelById(DiscordConstants.FEEDBACK_CHANNEL_ID);
    if (feedbackChannel == null) {
        return sendErrorMessage(message, "Invalid feedback channel defined, the text channel could not be found!");
    }

    PlaceholderMessage placeholderMessage = MessageFactory.makeEmbeddedMessage(feedbackChannel)
        .addField("Feedback", String.join(" ", args), false)
        .addField("Channel", buildChannel(message.getChannel()), false)
        .setFooter("Author ID: " + message.getAuthor().getId())
        .setTimestamp(Instant.now());

    placeholderMessage.setAuthor(
        message.getAuthor().getName() + "#" + message.getAuthor().getDiscriminator(),
        null,
        message.getAuthor().getEffectiveAvatarUrl()
    );

    if (message.getChannelType().isGuild() && message.getGuild() != null) {
        placeholderMessage.addField("Server", buildServer(message.getGuild()), false);
    }

    placeholderMessage.queue(newMessage -> {
        MessageFactory.makeSuccess(message, "Successfully sent feedback <:tickYes:319985232306765825>").queue();
    }, err -> {
        AvaIre.getLogger().error("Failed to send feedback message: " + err.getMessage(), err);
        MessageFactory.makeError(message, "Failed to send feedback message: " + err.getMessage()).queue();
    });

    return true;
}
项目:avaire    文件:Throttle.java   
public String generateCacheString(Message message, MiddlewareStack stack) {
    if (!this.equals(ThrottleType.USER) && message.getGuild() == null) {
        return USER.generateCacheString(message, stack);
    }

    String cacheFingerprint = generateCacheFingerprint(stack);

    switch (this) {
        case USER:
            return String.format(cache,
                message.getGuild() == null ? "private" : message.getGuild().getId(),
                message.getAuthor().getId(),
                cacheFingerprint);

        case CHANNEL:
            return String.format(cache,
                message.getGuild().getId(),
                message.getChannel().getId(),
                cacheFingerprint);

        case GUILD:
            return String.format(cache,
                message.getGuild().getId(),
                cacheFingerprint);

        default:
            return ThrottleType.USER.generateCacheString(message, stack);
    }
}
项目:Ducky-Mc-Duckerson    文件:UnflipCS.java   
@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)) {
        channel.sendMessage(author.getEffectiveName() + ": ┬─┬\uFEFF ノ( ゜-゜ノ)").queue();
        try {
            dbMan.incUserUnflipped(guildID, author.getUser().getIdLong());
        } catch (SQLException e) {
            channel.sendMessage(localize(channel, "command.unflip.error.sql")).queue();
        }
    }
}
项目:Ducky-Mc-Duckerson    文件:SetCommandLevelCS.java   
@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 (parameters.isEmpty()) {
            channel.sendMessage(localize(channel, "command.set_command_level.error.command_missing", dbMan.getPrefix(guildID) + commandName)).queue();
        }
        String[] paraList = parameters.split(" ");
        String cmdID = paraList[1];
        if (isInteger(paraList[2])) {
            Integer commandLevel = Integer.valueOf(paraList[2]);
            //TODO Check people's userlevel to make sure they can't assign a value higher than what they have.
            if (commandList.containsKey(cmdID)) {
                try {
                    dbMan.setCommandLevel(guildID, commandList.get(cmdID).commandID, commandLevel);
                    channel.sendMessage(localize(channel, "command.set_command_level.success", dbMan.getLevelName(guildID, commandLevel), cmdID)).queue();
                } catch (SQLException e) {
                    e.printStackTrace();
                    channel.sendMessage(localize(channel, "command.set_command_level.error.sql")).queue();
                }
            } else {

            }
        } else {
            channel.sendMessage(localize(channel, "command.set_command_level.error.syntax", dbMan.getPrefix(guildID) + commandName)).queue();
        }
    }

}
项目:Rubicon    文件:CommandPing.java   
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    //Returns a Message with Embed included
    return new MessageBuilder().setEmbed(new EmbedBuilder()
            .setDescription("Ping: " + RubiconBot.getJDA().getPing() + "ms")
            .setColor(Colors.COLOR_PRIMARY)
            .build()).build();
}
项目:avaire    文件:MemeCommand.java   
private boolean sendGeneratedMeme(Message message, String meme, String[] args) {
    if (args.length < 2) {
        return sendErrorMessage(message, "You must include the `top text` and `bottom text` arguments to generate a meme.");
    }

    MessageFactory.makeEmbeddedMessage(message.getChannel())
        .setImage(String.format(
            templateUrl,
            meme,
            formatMemeArgument(args[0]),
            formatMemeArgument(args[1])
        )).queue();

    return true;
}
项目:momo-2    文件:SetAutoRole.java   
@Override
public void executeCommand(Message msg) {
    GuildObject g = GuildObject.guildMap.get(msg.getGuild().getId());
    String roleName = Util.getCommandContents(msg);
    String currentRoleId = g.getConfig().getAutoAssignRoleId();
    EmbedBuilder em = new EmbedBuilder();
    if (roleName.isEmpty()) {
        MessageUtils.sendIncorrectCommandUsage(msg, this);
        return;
    }

    List<Role> roles = msg.getGuild().getRolesByName(roleName, true);
    if (roles.isEmpty()) {
        em.setTitle("Error", null)
        .setColor(Color.RED)
        .setDescription(String.format("No role named %s found", roleName));
        msg.getChannel().sendMessage(em.build()).queue();
        return;
    }
    Role r = roles.get(0);
    em.setTitle("Success", null);
    if (currentRoleId.equals(r.getId())) {
        em.setColor(Util.resolveColor(msg.getMember(), Color.CYAN))
        .setDescription(String.format("Removed **%s** as your auto assigned role", r.getName()));
        g.getConfig().setAutoAssignRoleId("");
    } else {
        em.setColor(Util.resolveColor(msg.getMember(), Color.CYAN))
        .setDescription(String.format("Set **%s** as your auto assigned role", r.getName()));
        g.getConfig().setAutoAssignRoleId(r.getId());
    }

    msg.getChannel().sendMessage(em.build()).queue();
}
项目:Uselessbot    文件:Voteutils.java   
public static List<Message> getVotes(Event event) {
    List<Message> votes = new ArrayList<>();

    voteMap.forEach((integer, Long) -> {
        votes.add(event.getJDA().getGuildById(Lib.LOG_GUILD)
                .getTextChannelsByName("votes", true).get(0)
                .getMessageById(voteMap.get(Long)).complete());
    });

    return votes;
}
项目:avaire    文件:CreatePlaylist.java   
@Override
public boolean onCommand(Message message, String[] args, GuildTransformer guild, Collection playlists) {
    String name = args[0].trim().split(" ")[0];
    List<DataRow> playlistItems = playlists.whereLoose("name", name);
    if (!playlistItems.isEmpty()) {
        MessageFactory.makeWarning(message, "The `:playlist` playlist already exists!")
            .set("playlist", name).queue();
        return false;
    }

    if (NumberUtil.isNumeric(name)) {
        MessageFactory.makeWarning(message, "The playlist can't only be numbers, you have to include some letters in the name!")
            .queue();
        return false;
    }

    int playlistLimit = guild.getType().getLimits().getPlaylist().getPlaylists();
    if (playlists.size() >= playlistLimit) {
        MessageFactory.makeWarning(message, "The server doesn't have any more playlist slots, you can delete existing playlists to free up slots.").queue();
        return false;
    }

    try {
        storeInDatabase(message, name);

        MessageFactory.makeSuccess(message,
            "The `:playlist` playlist has been been created successfully!\nYou can start adding songs to it with `:command :playlist add <song>`"
        ).set("playlist", name).set("command", command.generateCommandTrigger(message)).queue();

        return true;
    } catch (SQLException e) {
        e.printStackTrace();
        MessageFactory.makeError(message, "Error: " + e.getMessage()).queue();
    }

    return false;
}
项目:GiveawayBot    文件:RestJDA.java   
@CheckReturnValue
public MessageAction editMessage(long channelId, long messageId, Message newContent)
{
    Checks.notNull(newContent, "message");
    Route.CompiledRoute route = Route.Messages.EDIT_MESSAGE.compile(Long.toString(channelId), Long.toString(messageId));
    return new MessageAction(fakeJDA, route, new TextChannelImpl(channelId, new GuildImpl(fakeJDA, 0))).apply(newContent);
}
项目:GameResourceBot    文件:MessageListener.java   
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
    if (isFromMyself(event)) {
        return; // cancel on own messages
    }
    Message message = event.getMessage();
    String listeningChannel = BotConfig.getConfig().CHANNEL;
    String messageChannel = message.getChannel().getName();
    if (!listeningChannel.equalsIgnoreCase(messageChannel)) {
        return;
    }
    handleMessage(message);
}
项目:avaire    文件:IntelligenceManager.java   
private void sendRequest(Message message, String request) {
    try {
        AIResponse response = service.request(new AIRequest(request));

        String action = response.getResult().getAction();
        AvaIre.getLogger().info(ACTION_OUTPUT
            .replace("%action%", action)
            .replace("%author%", generateUsername(message))
            .replace("%server%", generateServer(message))
            .replace("%channel%", generateChannel(message))
            .replace("%message%", message.getRawContent())
            .replace("%response%", response.getResult().getFulfillment().getSpeech())
        );

        if (response.getStatus().getCode() != 200) {
            MessageFactory.makeError(message, response.getStatus().getErrorDetails()).queue();
            return;
        }

        for (Map.Entry<IntentAction, Intent> entry : INTENTS.entrySet()) {
            if (entry.getKey().isWildcard() && action.startsWith(entry.getKey().getAction())) {
                invokeIntent(message, response, entry.getValue());
                return;
            }

            if (entry.getKey().getAction().equals(action)) {
                invokeIntent(message, response, entry.getValue());
                return;
            }
        }
    } catch (AIServiceException e) {
        e.printStackTrace();
    }
}
项目:momo-2    文件:ReloadConfig.java   
@Override
public void executeCommand(Message msg) {
    Bot.getInstance().loadProperties();
    msg.getAuthor().openPrivateChannel().queue(ch -> {
        ch.sendMessage("Reloaded").queue();
    });
}
项目:GensokyoBot    文件:EventListenerBoat.java   
@Override
public void onMessageDelete(MessageDeleteEvent event) {
    if (messagesToDeleteIfIdDeleted.containsKey(event.getMessageId())) {
        Message msg = messagesToDeleteIfIdDeleted.remove(event.getMessageId());
        if (msg.getJDA() == event.getJDA()) {
            msg.delete().queue();
        }
    }
}
项目:JDodoBot    文件:Magic8Ball.java   
@Override
public void doYaThing(Message message) {
    try {
        message.getTextChannel().sendMessage(answers[RandomGen.rndNm(answers.length)]).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        Bot.log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:avaire    文件:ShardCommand.java   
@Override
public boolean onCommand(Message message, String[] args) {
    if (avaire.getShards().size() < 2) {
        CommandContainer container = CommandHandler.getCommand(StatsCommand.class);
        if (container == null) {
            return sendErrorMessage(message, "Sharding is not enabled right now :(");
        }
        return container.getCommand().onCommand(message, args);
    }

    List<String> messages = new ArrayList<>();
    messages.add("**All Shards**```prolog");

    for (AvaireShard shard : avaire.getShards()) {
        messages.add(String.format("%s : G %s, C %s, U %s%s",
            shard.getShardId(),
            shard.getJDA().getGuilds().size(),
            shard.getJDA().getTextChannels().size() + shard.getJDA().getVoiceChannels().size(),
            shard.getJDA().getUsers().size(),
            shard.getShardId() == message.getJDA().getShardInfo().getShardId() ? " <--" : ""
        ));
    }
    messages.add("```");

    messages.add("**Total Shards**```ml");
    messages.add(String.format("G %s, C %s, U %s",
        avaire.getShardEntityCounter().getGuilds(),
        avaire.getShardEntityCounter().getChannels(),
        avaire.getShardEntityCounter().getUsers()
    ));
    messages.add("```");

    MessageFactory.makeInfo(message, String.join("\n", messages)).queue();
    return true;
}
项目:Rubicon    文件:CommandWarn.java   
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    if (parsedCommandInvocation.getArgs().length <= 0) {
        return createHelpMessage();
    }
    switch (parsedCommandInvocation.getArgs()[0]) {
        case "list":
            return warnList(parsedCommandInvocation);
        case "remove":
        case "unwarn":
            return unwarnUser(parsedCommandInvocation);
        default:
            return warnUser(parsedCommandInvocation);
    }
}
项目:avaire    文件:RandomCatCommand.java   
@Override
public boolean onCommand(Message message, String[] args) {
    RequestFactory.makeGET("http://random.cat/meow")
        .send((Consumer<Response>) response -> {
            RandomCatService service = (RandomCatService) response.toService(RandomCatService.class);

            MessageFactory.makeEmbeddedMessage(message.getChannel())
                .setImage(service.getFile()).queue();
        });
    return true;
}
项目:Supreme-Bot    文件:DefaultMessageEvent.java   
@Override
public Message sendAndWaitMessage(MessageEmbed message_) {
    try {
        if (isPrivate()) {
            return Util.sendAndWaitPrivateMessage(message.getAuthor(), message_);
        } else {
            return message.getChannel().sendMessage(message_).complete();
        }
    } catch (Exception ex) {
        if (DEBUG) {
            ex.printStackTrace();
        }
        return null;
    }
}
项目:Rubicon    文件:CommandAutorole.java   
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    if (parsedCommandInvocation.getArgs().length < 1) {
        return createHelpMessage();
    }
    if (parsedCommandInvocation.getMessage().getMentionedRoles().size() <1){
        String toset = parsedCommandInvocation.getMessage().getGuild().getRolesByName(parsedCommandInvocation.getArgs()[0],true).get(0).getId();
        RubiconBot.getMySQL().updateGuildValue(parsedCommandInvocation.getMessage().getGuild(), "autorole", toset);
    }else {
        RubiconBot.getMySQL().updateGuildValue(parsedCommandInvocation.getMessage().getGuild(), "autorole", parsedCommandInvocation.getMessage().getMentionedRoles().get(0).getId());
    }
    return new MessageBuilder().setEmbed(EmbedUtil.success("Succes","Succesfully set the Autorole!").build()).build();
}