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

项目:Blizcord    文件:Jump.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    if(!AudioPlayerThread.isPlaying()) {
        channel.sendMessage(author.getAsMention() + " ``Currently I'm not playing.``").queue();
        return;
    }

    int seconds;
    if(arg == null) {
        seconds = 10;
    } else {
        try {
            seconds = Integer.parseInt(arg);
            if(seconds == 0) {
                throw new NumberFormatException();
            }
        } catch(NumberFormatException e) {
            channel.sendMessage(author.getAsMention() +  " ``Invalid number``").queue();
            return;
        }
    }

    AudioTrack track = AudioPlayerThread.getMusicManager().player.getPlayingTrack();
    track.setPosition(track.getPosition() + (1000*seconds)); // Lavaplayer handles values < 0 or > track length
}
项目:JDodoBot    文件:Speak.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) {
            message.delete().complete();
            String whatToSay = DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 1);
            channel.sendMessage(whatToSay.substring(0, 1).toUpperCase() + whatToSay.substring(1) + ".").complete();
        } else {
            channel.sendMessage(getUsage()).complete();
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:JDodoBot    文件:Triggered.java   
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    User author = message.getAuthor();
    try {
        BufferedImage avatar = ReadImage.readImageFromURL(author.getAvatarUrl());
        BufferedImage triggered = ReadImage.readImageFromDisk("triggered.jpg");
        DrawOnImg.drawImg(avatar, triggered, 0, avatar.getHeight() - 20, avatar.getWidth(), 20);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(avatar, "png", baos);
        channel.sendFile(baos.toByteArray(), "triggered.png", null).complete();

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:JuniperBotJ    文件:WelcomeUserListener.java   
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
    WelcomeMessage message = welcomeMessageRepository.findByGuild(event.getGuild());
    if (message == null || !message.isJoinEnabled() || (!message.isJoinToDM() && message.getJoinChannelId() == null)) {
        return;
    }

    MessageChannel channel = null;
    if (message.isJoinToDM() && !event.getJDA().getSelfUser().equals(event.getUser())) {
        User user = event.getUser();
        try {
            channel = user.openPrivateChannel().complete();
        } catch (Exception e) {
            LOGGER.error("Could not open private channel for user {}", user, e);
        }
    }
    if (channel == null) {
        channel = event.getGuild().getTextChannelById(message.getJoinChannelId());
    }
    send(event, channel, message.getJoinMessage(), message.isJoinRichEnabled());
}
项目: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();
        }


    }

}
项目:Ducky-Mc-Duckerson    文件:WerewolfJoinCS.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 (!dbMan.isWerewolfOn(guildID)) {
        //Werewolf is turned off for this guild, so ignore the command
        return;
    }

    if (hasPermission(author)) {
        //check to make sure that we're in a gamestarted state
        GameState gs = ww.getWerewolfGameState(guildID);
        if (gs != null && gs == GameState.GAMESTART) {
            ww.joinGame(guildID, author);
        }
    }
}
项目:JDodoBot    文件:About.java   
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    EmbedBuilder embMsg = new EmbedBuilder();
    try {
        embMsg.setTitle("About DodoBot", "https://github.com/ExidCuter/JDodoBot");
        embMsg.setThumbnail("https://pbs.twimg.com/profile_images/932637770874589186/KgP5zJjH_400x400.jpg");
        embMsg.setColor(new Color(0x13FF00));
        embMsg.addField("Version", ver, true);
        embMsg.addField("By", "Dodo Dodović", true);
        embMsg.addField("Servers", Integer.toString(getNumOfServers()), true);
        embMsg.addField("GitHub", "https://github.com/ExidCuter/JDodoBot", false);
        embMsg.addField("Donate", " https://www.paypal.me/DodoDodovic", false);
        channel.sendMessage(embMsg.build()).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:Rubicon    文件:CommandSlot.java   
private void sendHelpMessage(MessageChannel channel) {
    channel.sendMessage(
            new EmbedBuilder()
                    .setColor(new Color(22, 138, 233))
                    .setDescription("__**WINNING OPTIONS FOR SLOT MACHINE**__\n`" + "slot <money> - 3 of a kind wins!`\n\n\n")

                    .addField("Winning multiplicator: x2",
                            ":bell: :football: :soccer: :8ball: :green_apple: :lemon: :strawberry: :watermelon:",  false)

                    .addField("Winning multiplicator: x3",
                            ":heart: :yellow_heart: :blue_heart: :green_heart:",  false)

                    .addField("Winning multiplicator: x5",
                            ":star2: :zap:",  false)

                    .addField("Winning multiplicator: x8",
                            ":diamonds:",  false)

                    .build()
    ).queue();
}
项目:pokeraidbot    文件:NewRaidGroupCommand.java   
public static void cleanUpRaidGroupAndDeleteSignUpsIfPossible(MessageChannel messageChannel,
                                                              LocalDateTime startAt, String raidId,
                                                              EmoticonSignUpMessageListener emoticonSignUpMessageListener,
                                                              RaidRepository raidRepository,
                                                              BotService botService, String groupId) {
    Raid raid = null;
    try {
        if (startAt != null && raidId != null) {
            // Clean up all signups that should have done their raid now, if there still is a time
            // (Could be set to null due to an error, in that case keep signups in database)
            raid = raidRepository.removeAllSignUpsAt(raidId, startAt);
        }
    } catch (Throwable t) {
        // Do nothing, just log
        LOGGER.warn("Exception occurred when removing signups: " + t + "-" + t.getMessage());
        if (t instanceof ConcurrentModificationException) {
            LOGGER.warn("This is probably due to raid being removed while cleaning up signups, which is normal.");
        }
    } finally {
        final String raidDescription = raid == null ? "null" : raid.toString();
        cleanUpGroupMessageAndEntity(messageChannel, raidId, emoticonSignUpMessageListener, raidRepository,
                botService, groupId, raidDescription);
    }
}
项目:Amme    文件:Restart.java   
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
if (core.permissionHandler.check(4,event)) return;
    MessageChannel channel = event.getChannel();
    channel.sendTyping().queue();
    event.getMessage().delete().queue();

    util.embedSender.sendEmbed(":battery: System Restarting!", channel, Color.GREEN);

    //Code by ZekroTJA(github.com/ZekroTJA)
    if (System.getProperty("os.name").toLowerCase().contains("linux"))
        Runtime.getRuntime().exec("screen python restart.py");

    System.exit(0);

}
项目:Blizcord    文件:Next.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    if(!AudioPlayerThread.isPlaying()) {
        channel.sendMessage(author.getAsMention() + " ``Currently I'm not playing.``").queue();
        return;
    }

    int skips;
    if (arg == null) {
        skips = 1;
    } else {
        try {
            skips = Integer.parseInt(arg);
            if (skips < 1) {
                throw new NumberFormatException();
            }
        } catch (NumberFormatException e) {
            channel.sendMessage(author.getAsMention() + " ``Invalid number``").queue();
            return;
        }
    }

    AudioPlayerThread.getMusicManager().scheduler.nextTrack(skips);
}
项目:pokeraidbot    文件:NewRaidGroupCommand.java   
private static void assertAllParametersOk(MessageChannel channel, Config config, User user, Locale locale,
                                          LocalTime startAtTime, String raidId, LocaleService localeService,
                                          RaidRepository raidRepository, BotService botService,
                                          ServerConfigRepository serverConfigRepository,
                                          PokemonRepository pokemonRepository, GymRepository gymRepository,
                                          ClockService clockService, ExecutorService executorService) {
    Validate.notNull(channel, "Channel");
    Validate.notNull(config, "config");
    Validate.notNull(user, "User");
    Validate.notNull(locale, "Locale");
    Validate.notNull(startAtTime, "StartAtTime");
    Validate.notNull(localeService, "LocaleService");
    Validate.notNull(raidRepository, "RaidRepository");
    Validate.notNull(botService, "BotService");
    Validate.notNull(serverConfigRepository, "ServerConfigRepository");
    Validate.notNull(pokemonRepository, "PokemonRepository");
    Validate.notNull(gymRepository, "GymRepository");
    Validate.notNull(clockService, "ClockService");
    Validate.notNull(executorService, "ExecutorService");
    Validate.notEmpty(raidId, "Raid ID");
}
项目:Blizcord    文件:Help.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    channel.sendMessage(author.getAsMention() + " **Commands:**\n"
            + "```"
            + "!list                           (Show the playlist)\n"
            + "!play <file or link>            (Play given track now)\n"
            + "!add <file, folder or link>     (Add given track to playlist)\n"
            + "!search <youtube video title>   (Plays the first video that was found)\n"
            + "!save <name>                    (Save the current playlist)\n"
            + "!load <name>                    (Load a saved playlist)\n"
            + "!lists                          (List the saved playlists)\n"
            + "!pause                          (Pause or resume the current track)\n"
            + "!stop                           (Stop the playback and clear the playlist)\n"
            + "!volume                         (Change the playback volume)\n"
            + "!next (<how many songs>)        (Skip one or more songs from the playlist)\n"
            + "!seek <hours:minutes:seconds>   (Seek to the specified position)\n"
            + "!jump (<how many seconds>)      (Jump forward in the current track)\n"
            + "!repeat (<how many times>)      (Repeat the current playlist)\n"
            + "!shuffle                        (Randomize the track order)\n"
            + "!loop                           (Re add played track to the end of the playlist)\n"
            + "!uptime                         (See how long the bot is already online)\n"
            + "!about                          (Print about message)\n"
            + "!kill                           (Kill the bot)"
            + "```"
            + (channel.getType() == ChannelType.PRIVATE ? ("\n**Guild:** " + guild.getName()) : "") ).queue();
}
项目:Phonon    文件:ConfirmAccountLinkCommand.java   
@Override
public void execute(User user, CommandContext args, MessageChannel channel) {
    String code = (String) args.getOne("code").get();
    //link successful
    if (this.bot.getCodes().containsKey(code)) {
        org.spongepowered.api.entity.living.player.User spongeUser = Sponge.getServiceManager().provideUnchecked(UserStorageService.class)
                .get(bot.getCodes().get(code)).get();
        spongeUser.getSubjectData().setOption(SubjectData.GLOBAL_CONTEXT, "discord-user", user.getId());

        AccountConfigData data = (AccountConfigData) this.phonon.getAllConfigs().get(AccountConfigData.class);
        data.getAccounts().put(user.getId(), spongeUser.getUniqueId());
        data.save();

        channel.sendMessage("You have successfully linked " + user.getName() + "#" +user.getDiscriminator()
                + " to " + spongeUser.getName()).queue();
    } else {
        channel.sendMessage("That is not a valid code!").queue();
    }

}
项目:JDodoBot    文件:HelpMusic.java   
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    try {
        String helpVoice = "join [name]  - Joins a voice channel that has the provided name\njoin [id]    - Joins a voice channel based on the provided id.\nleave        - Leaves the voice channel that the bot is currently in.\nplay         - Plays songs from the current queue. Starts playing again if it was previously paused\nplay [url]   - Adds a new song to the queue and starts playing if it wasn't playing already\npplay        - Adds a playlist to the queue and starts playing if not already playing\npause        - Pauses audio playback\nstop         - Completely stops audio playback, skipping the current song.\nskip         - Skips the current song, automatically starting the next\nnowplaying   - Prints information about the currently playing song (title, current time)\nnp           - alias for nowplaying\nlist         - Lists the songs in the queue\nvolume [val] - Sets the volume of the MusicPlayer [10 - 100]\nrestart      - Restarts the current song or restarts the previous song if there is no current song playing.\nrepeat       - Makes the player repeat the currently playing song\nreset        - Completely resets the player, fixing all errors and clearing the queue.\n";
        channel.sendMessage("```Voice Commands:  \n" + helpVoice + "```").complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:Ducky-Mc-Duckerson    文件:HTMLParse.java   
public void StartScheduledUpdates(MessageChannel channel) {
    scheduler.scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
            HTMLParse.get_instance().GetTodayCalendarData(channel);
        }
    }, 0, 3L, TimeUnit.HOURS);
}
项目:Ducky-Mc-Duckerson    文件:DatabaseManager.java   
public String getLocale(MessageChannel channel) {
    String locale = I18N.DEFAULT_LOCALE;
    long channelId = channel.getIdLong();

    try {
        String sql = "SELECT locale FROM locale_settings WHERE snowflake_id = ?";
        PreparedStatement stmt = conn.prepareStatement(sql);
        stmt.setLong(1, channelId);
        ResultSet rs = stmt.executeQuery();

        if (rs.next()) {
            locale = rs.getString("locale");
        } else {
            if (channel instanceof TextChannel) {
                // Try to fallback to guild settings
                long guildID = ((TextChannel) channel).getGuild().getIdLong();
                stmt = conn.prepareStatement(sql);
                stmt.setLong(1, guildID);
                rs = stmt.executeQuery();
                locale = rs.getString("locale");
            }
        }
    } catch (SQLException e) {
        new Exception("Failed to find locale", e).printStackTrace();
    }

    return locale;
}
项目:pokeraidbot    文件:StartUpEventListener.java   
@Override
public void onEvent(Event event) {
    if (event instanceof ReadyEvent) {
        final List<Guild> guilds = event.getJDA().getGuilds();
        for (Guild guild : guilds) {
            Config config = serverConfigRepository.getConfigForServer(guild.getName().trim().toLowerCase());
            if (config != null) {
                final String messageId = config.getOverviewMessageId();
                if (!StringUtils.isEmpty(messageId)) {
                    for (MessageChannel channel : guild.getTextChannels()) {
                        if (attachToOverviewMessageIfExists(guild, config, messageId, channel)) {
                            break;
                        } else {
                            if (LOGGER.isDebugEnabled()) {
                                LOGGER.debug("Didn't find overview in channel " + channel.getName());
                            }
                        }
                    }
                }

                final List<RaidGroup> groupsForServer = raidRepository.getGroupsForServer(config.getServer());
                for (RaidGroup group : groupsForServer) {
                    attachToGroupMessage(guild, config, group);
                }
            }
        }
    }
}
项目:JuniperBotJ    文件:AudioMessageManager.java   
public void onQueue(MessageChannel sourceChannel, BotContext context, List<TrackRequest> requests, int pageNum) {
    initLocale(sourceChannel);
    final int pageSize = 25;
    List<List<TrackRequest>> parts = Lists.partition(requests, pageSize);
    final int totalPages = parts.size();
    final int offset = (pageNum - 1) * pageSize + 1;

    final long totalDuration = requests.stream()
            .filter(Objects::nonNull)
            .map(TrackRequest::getTrack)
            .filter(Objects::nonNull)
            .mapToLong(AudioTrack::getDuration).sum();

    if (pageNum > totalPages) {
        onQueueError(sourceChannel, "discord.command.audio.queue.list.totalPages", parts.size());
        return;
    }
    List<TrackRequest> pageRequests = parts.get(pageNum - 1);

    EmbedBuilder builder = getQueueMessage();
    for (int i = 0; i < pageRequests.size(); i++) {
        TrackRequest request = pageRequests.get(i);
        AudioTrack track = request.getTrack();
        AudioTrackInfo info = track.getInfo();

        int rowNum = i + offset;
        String title = messageService.getMessage("discord.command.audio.queue.list.entry", rowNum,
                CommonUtils.formatDuration(track.getDuration()), rowNum == 1 ? ":musical_note: " : "",
                getTitle(info), info.uri, request.getMember().getEffectiveName());
        builder.addField(EmbedBuilder.ZERO_WIDTH_SPACE, title, false);
    }
    builder.setFooter(totalPages > 1
            ? messageService.getMessage("discord.command.audio.queue.list.pageFooter",
            pageNum, totalPages, requests.size(), CommonUtils.formatDuration(totalDuration),
            context.getConfig().getPrefix())
            : messageService.getMessage("discord.command.audio.queue.list.footer",
            requests.size(), CommonUtils.formatDuration(totalDuration)), null);
    messageService.sendMessageSilent(sourceChannel::sendMessage, builder.build());
}
项目:BullyBot    文件:TeamPickerMenu.java   
private Menu getMenu(MessageChannel c){
    for(Menu m : menus){
        if(m.getChannel().equals(c)){
            return m;
        }
    }
    return null;
}
项目:Ducky-Mc-Duckerson    文件:WerewolfStartCS.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 (!dbMan.isWerewolfOn(guildID)) {
        //Werewolf is turned off for this guild, so ignore the command
        return;
    }

    if (hasPermission(author)) {
        //Check to make sure we do not have a game running (null GameState or IDLE)
        GameState gs = ww.getWerewolfGameState(guildID);
        if (gs == null || gs == GameState.IDLE) {
            parameters = parameters.trim();
            if (isInteger(parameters)) {
                Integer themeID = Integer.valueOf(parameters);
                if (!ww.getIsRulesSent(guildID)) {
                    //TODO Remind players how to find out about the rules
                    ww.sendRuleToChannel(channel, guildID);
                }

                if (ww.startTheme(guildID, themeID)) {
                    ww.startGame(author.getGuild(), author, channel);
                } else {
                    //TODO Alert players to invalid theme ID;
                    channel.sendMessage("Invalid theme ID, I don't know any theme by " + themeID + " Syntax: " + dbMan.getPrefix(guildID) + commandName + " [themeID]").queue();
                }

            } else {
                //We need an id to select a theme
                channel.sendMessage("Start a game of werewolf, Syntax: " + dbMan.getPrefix(guildID) + commandName + " [themeID]").queue();
            }
        } else {
            //A Game is currently running, user will need to wait until the game is finished
            channel.sendMessage("There's a game already running, please wait for that game to finish").queue();
        }
    }

}
项目:JDodoBot    文件:SlotMashina.java   
public static void slotMashinas(double money, MessageChannel msgchan, BankAccount ba) {
    int slotMashina[][] = {{-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}};
    String endGame = "";
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            slotMashina[i][j] = ThreadLocalRandom.current().nextInt(0, slots.length - 1);
        }
        if (i == 1) {
            endGame = endGame + slots[slotMashina[i][0]] + " " + slots[slotMashina[i][1]] + " " + slots[slotMashina[i][2]] + " :arrow_left:\n";
        } else {
            endGame = endGame + slots[slotMashina[i][0]] + " " + slots[slotMashina[i][1]] + " " + slots[slotMashina[i][2]] + "\n";
        }
    }
    msgchan.sendMessage(endGame).complete();
    String out;
    if (slotMashina[1][0] == slotMashina[1][1] && slotMashina[1][1] == slotMashina[1][2]) {
        money = money * 3;
        out = "Three the same. WOW! +3x!";
    } else if (slotMashina[1][0] == slotMashina[1][1] || slotMashina[1][1] == slotMashina[1][2] || slotMashina[1][0] == slotMashina[1][2]) {
        money = money * 1.5;
        out = "Two the same. +1.5x!";
    } else {
        money = money * -1;
        out = "You lost. Better luck next time!";
    }
    msgchan.sendMessage(out + " Winnings: " + Double.toString(money) + "\n" + ba.getBalance() + "-->" + (ba.getBalance() + money) + " Dodos").complete();

    ba.setBalance(ba.getBalance() + money);
    FileHandler.writeToFile(Bot.bankAccounts);
}
项目: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();
        }
    }

}
项目:Ducky-Mc-Duckerson    文件:ListUserInvCS.java   
private void sendUserInv(Member member, MessageChannel channel, String prefix, Color color, Member requestedBy) {
    EmbedBuilder embed = new EmbedBuilder();
    Long guildID = member.getGuild().getIdLong();
    Long userID = member.getUser().getIdLong();
    UserProfile up;

    try {
        up = dbMan.getUserProfile(guildID, userID);
        HashMap<Long, Item> inv = up.getInv();

        embed.setColor(color);
        embed.setAuthor(localize(channel, "command.inv.title", member.getEffectiveName()), null, member.getUser().getAvatarUrl());
        if (inv.isEmpty()) {
            embed.addField(localize(channel, "command.inc.inventory"), localize(channel, "command.inv.empty"), false);
        } else {
            for (Item item : inv.values()) {
                embed.addField(localize(channel, "command.inv.item", item.getLocalizedName(channel), item.getItemID()), item.getDescription(channel), true);
            }
        }

        if (requestedBy != null)
            embed.addField("", localize(channel, "command.inv.requested_by", member.getEffectiveName(), requestedBy.getEffectiveName()), false);
        embed.setFooter(localize(channel, "command.inv.usage", prefix + commandName), null);
        embed.setTimestamp(Instant.now());

        embed.setThumbnail(member.getUser().getAvatarUrl());
        channel.sendMessage(embed.build()).queue();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
项目:Ducky-Mc-Duckerson    文件:AliasMappingCS.java   
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
  Long guildID = author.getGuild().getIdLong();
  CommandStructure command = commandMapping.get(guildID);
  if (command != null) {
      command.execute(author, authorUser, channel, message, parameters, commandList);
  }
}
项目:JuniperBotJ    文件:AudioMessageManager.java   
public void onEmptyQueue(MessageChannel sourceChannel) {
    initLocale(sourceChannel);
    EmbedBuilder builder = getQueueMessage();
    builder.setColor(Color.RED);
    builder.setDescription(messageService.getMessage("discord.command.audio.queue.empty"));
    messageService.sendMessageSilent(sourceChannel::sendMessage, builder.build());
}
项目:JDodoBot    文件:Payday.java   
@Override
public void doYaThing(Message message) {
    User author = message.getAuthor();
    MessageChannel channel = message.getChannel();

    BankAccount temp = new BankAccount("temp");
    boolean exists = false;
    for (BankAccount b : bankAccounts) {
        if (b.getID().equals(author.getId())) {
            exists = true;
            temp = b;
        }
    }
    try {
        if (exists && temp.lastPay.before(new Date(System.currentTimeMillis() - TimeUnit.HOURS.toMillis(23)))) {
            temp.setBalance(temp.getBalance() + 100.00);
            temp.lastPay = new Date();
            channel.sendMessage("You got 100.00 Dodos.\nNew balance: " + Double.toString(temp.getBalance())).complete();
            FileHandler.writeToFile(bankAccounts);
        } else {
            channel.sendMessage("You have already got your pay!").complete();
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:Ducky-Mc-Duckerson    文件:ItemDatabase.java   
public void obtainItem(Integer invID, Guild guild, Member member, MessageChannel channel, Integer amount) {
    if (fullInv.containsKey(invID)) {
        fullInv.get(invID).execute(guild, member, channel, amount);
    } else {
        //TODO ERROR
    }
}
项目:Ducky-Mc-Duckerson    文件:TesterTitleItem.java   
@Override
public void executeUse(Guild guild, Member member, MessageChannel channel) {
    Long guildID = guild.getIdLong();
    Long userID = member.getUser().getIdLong();
    try {
        // TODO: localize title?
        dbMan.setUserTitle(guildID, userID, this.getName());
        channel.sendMessage(localize(channel, "item.tester_title.title_set", this.getLocalizedName(channel))).queue();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
项目:Rubicon    文件:EmbedUtil.java   
/**
 * Sends a message and deletes it after an interval (if interval is >= 0).
 *
 * @param messageChannel         the channel to send the message in.
 * @param message                the message to send.
 * @param deleteInterval         the interval after that the message should be deleted. Message won't be deleted if
 *                               interval is < 0.
 * @param deleteIntervalTimeUnit the TimeUnit of deleteInterval.
 */
public static void sendAndDelete(MessageChannel messageChannel, Message message, long deleteInterval, TimeUnit deleteIntervalTimeUnit) {
    messageChannel.sendMessage(message).queue(deleteInterval < 0
            // do nothing if interval < 0
            ? null
            // else: delete after interval
            : sentMessage -> sentMessage.delete().queueAfter(deleteInterval, deleteIntervalTimeUnit, null, ignored -> {
        //TODO evaluate exception, i.e. bot does not have permission
    }));
}
项目:Amme    文件:Achivment.java   
public static void level10(User user, MessageChannel channel) {
    channel.sendMessage(new EmbedBuilder()

            .setThumbnail("http://www.bilder-upload.eu/upload/910508-1507225009.png")
            .setColor(Color.RED)
            .setTitle("Wow,  " + user.getName() + " you Got Level 10! \n")
            .setDescription("You got ...(WIP)[Nothing]")
            .build()

    ).queue();
    LVL.updateValue(user, "lvl10", "1");
}
项目:JuniperBotJ    文件:MessageServiceImpl.java   
@Override
public void onTitledMessage(MessageChannel sourceChannel, String titleCode, String code, Object... args) {
    if (StringUtils.isEmpty(titleCode)) {
        sendMessageSilent(sourceChannel::sendMessage, getMessage(code, args));
        return;
    }
    sendMessageSilent(sourceChannel::sendMessage, createMessage(titleCode, code, args).build());
}
项目:JDodoBot    文件:Cat.java   
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    try {
        channel.sendMessage(HTTPHandler.getCat()).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:Saber-Bot    文件:MessageUtilities.java   
public static void sendMsg(Message message, MessageChannel chan, Consumer<Message> action, Consumer<Throwable> error )
{
    if(message.getContent().isEmpty() && message.getEmbeds().isEmpty()) return;

    try
    {
        chan.sendMessage(message).queue(action, error);
    }
    catch(Exception e)
    {
        Logging.warn(MessageUtilities.class, e.getMessage());
    }
}
项目:Blizcord    文件:Loop.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    if(AudioPlayerThread.loop) {
        AudioPlayerThread.loop = false;
        channel.sendMessage(author.getAsMention() + " Looping: ``disabled``").queue();
    } else {
        AudioPlayerThread.loop = true;
        channel.sendMessage(author.getAsMention() + " Looping: ``enabled``").queue();
    }
}
项目:Blizcord    文件:Load.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    // arg = playlist name
    if(arg == null) {
        channel.sendMessage(author.getAsMention() + " ``Please specify a playlist name. Put it behind this command.``").queue();
        return;
    }
    // Load the playlist
    try {
        File playlistFile = new File(new File(Config.getAppDir(), "playlists"), arg);
        if(!playlistFile.exists()) {
            channel.sendMessage(author.getAsMention() + " Playlist doesn't exist: ``" + arg + "``").queue();
            return;
        }

        // Join the voice channel of the command author before addToPlaylist() joins the default channel
        Bot.joinVoiceChannel(Bot.getGuild().getMember(author));

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(playlistFile), StandardCharsets.UTF_8));
        String line;
        while((line = bufferedReader.readLine()) != null) {
            AudioPlayerThread.addToPlaylist(line, true);
        }
        bufferedReader.close();

        channel.sendMessage(author.getAsMention() + " Playlist loaded: ``" + arg + "``").queue();
    } catch (Exception e) {
        channel.sendMessage(author.getAsMention() + " Failed to load playlist: ``" + arg + "``").queue();
    }
}
项目:JDodoBot    文件:Slot.java   
@Override
public void doYaThing(Message message) {
    User author = message.getAuthor();
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    BankAccount temp = new BankAccount("temp");
    boolean exists = false;
    for (BankAccount b : bankAccounts) {
        if (b.getID().equals(author.getId())) {
            exists = true;
            temp = b;
        }
    }
    try {
        if (commandNParameters.length < 2)
            channel.sendMessage("```" + prefix + usage + "```").complete();
        else if (exists && temp.getBalance() >= Double.parseDouble(commandNParameters[1])) {
            if (Double.parseDouble(commandNParameters[1]) > -1)
                SlotMashina.slotMashinas(Double.parseDouble(commandNParameters[1]), channel, temp);
            else
                channel.sendMessage("Can't slot that!").complete();
        } else {
            if (!exists) {
                channel.sendMessage("You have to register! Use `" + prefix + "bank register`").complete();
            } else channel.sendMessage("You are too poor!").complete();
        }

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:avaire    文件:MessageFactory.java   
public static PlaceholderMessage makeEmbeddedMessage(MessageChannel channel, Color color, Field... fields) {
    PlaceholderMessage message = new PlaceholderMessage(channel,
        createEmbeddedBuilder().setColor(color),
        null
    );

    Arrays.stream(fields).forEachOrdered(message::addField);
    return message;
}
项目:Blizcord    文件:Play.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    if(arg == null) {
        channel.sendMessage(author.getAsMention() + " ``Please specify what I should play. Put it behind this command.``").queue();
        return;
    }

    // Join the voice channel of the command author before playDirect() joins the default channel
    Bot.joinVoiceChannel(Bot.getGuild().getMember(author));

    AudioPlayerThread.playDirect(arg, false);
}
项目:Blizcord    文件:Save.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    // arg = playlist name
    if(arg == null) {
        channel.sendMessage(author.getAsMention() + " ``Please specify a playlist name. Put it behind this command.``").queue();
        return;
    }
    if(!AudioPlayerThread.isPlaying()) {
        channel.sendMessage(author.getAsMention() + " ``The playlist is empty, nothing to save.``").queue();
        return;
    }
    File playlistsFolder = new File(Config.getAppDir(), "playlists");
    if(!playlistsFolder.exists()) {
        if(!playlistsFolder.mkdir()) {
            channel.sendMessage(author.getAsMention() + " ``Failed to create playlists folder.``").queue();
            return;
        }
    }
    try {
        BufferedWriter writer = new BufferedWriter(new FileWriterWithEncoding(new File(playlistsFolder, arg), StandardCharsets.UTF_8, false));
        // Write currently playing track
        writer.write(AudioPlayerThread.getMusicManager().player.getPlayingTrack().getInfo().uri);
        writer.newLine();
        // Write upcoming tracks
        ArrayList<AudioTrack> upcoming = AudioPlayerThread.getMusicManager().scheduler.getList();
        if(!upcoming.isEmpty()) {
            for(int i = 0; i < upcoming.size(); i++) {
                writer.write(upcoming.get(i).getInfo().uri);
                writer.newLine();
            }
        }
        // Save
        writer.close();

        channel.sendMessage(author.getAsMention() + " Playlist saved: ``" + arg + "``").queue();
    } catch (Exception e) {
        channel.sendMessage(author.getAsMention() + " ``Failed to save playlist.``").queue();
    }
}