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


Java JDABuilder.buildAsync方法代碼示例

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


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

示例1: main

import net.dv8tion.jda.core.JDABuilder; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, IllegalArgumentException, LoginException {

        new Logger();

        Logger.info("Initializing the bot...");

        Logger.log("Loading Config Files...");
        createConfigFiles();

        String token = readFirstLineOfFile("config.yml", "There is no token in your config, welcome to stack trace city!");
        theme = readFirstLineOfFile("theme.yml", "Error receiving theme");

        String sqlPassword;
        sqlPassword = readFirstLineOfFile("sql.yml", "Error receiving your SQL Password");

        themeManager = loadThemeManager();
        messageFactory = loadMessageFactory();

        loadTweetMonitor();

        //Load our SQL Stuff
        sqlManager = new SQLManager(sqlPassword);

        Logger.info("Loading Warning Manager...");
        warningManager = new WarningManager(sqlManager);

        Logger.info("Loading Report Manager...");
        reportManager = new ReportManager(sqlManager);

        Logger.info("Loading the Hypixel API...");
        loadHypixelAPI();

        List<EventListener> eventListeners = loadEventListeners();
        loadClientBuilder();

        Logger.info("Constructing the JDA Instance...");
        JDABuilder builder = new JDABuilder(AccountType.BOT)
                .setToken(token)
                .setStatus(OnlineStatus.DO_NOT_DISTURB)
                //Listens to the MessageReceivedEvent.
                .addEventListener(clientBuilder.build())
                .setGame(Game.of(Game.GameType.DEFAULT, "Loading"));
        for (EventListener listener : eventListeners)
            builder.addEventListener(listener);
        jda = builder.buildAsync();

//        new RichPresence((JDAImpl) jda);

        Logger.info("Bot has been loaded!");
    }
 
開發者ID:WheezyGold7931,項目名稱:happybot,代碼行數:51,代碼來源:Main.java

示例2: main

import net.dv8tion.jda.core.JDABuilder; //導入方法依賴的package包/類
public static void main(String[] args) throws LoginException, InterruptedException, RateLimitedException {
    String token = GSONUtils.getConfig().getToken();
    if (GSONUtils.getConfig().getDcoinToken() != null) {
        discoin = new Discoin4J(GSONUtils.getConfig().getDcoinToken());
        discoinManager = new DiscoinManager();
    }

    if (shards == 0) {
        System.out.println("You must enter the number of shards in your \"config.json\"! Please go back and specify it before launching.");
        System.exit(0);
    }

    if (token == null) {
        System.out.println("Token was not specified in \"config.json\"! Please go back and specify one before launching!");
    } else {
        JDABuilder builder = new JDABuilder(AccountType.BOT).setToken(token)
                .setReconnectQueue(new SessionReconnectQueue())
                .addEventListener(new Listener())
                .addEventListener(waiter)
                .addEventListener(gamesManager);

        if (shards > 1) {
            for (int i = 0; i < shards; i++) {
                jdas[i] = builder.useSharding(i, shards).buildAsync();
            }
        } else {
            jdas[0] = builder.buildAsync();
        }
        for (JDA jda : jdas) {
            CommandRegistry.getForClient(jda).registerAll(Help.help, Purge.purge, Say.say, Granddad.granddad, TicketCommand.ticket, Lenny.lenny,
                    Shrug.shrug, Credits.credits, Avatar.avatar, TagCommand.tagCommand, AddAllowedUser.addAllowedUser, AddGame.addGame, Triggered.triggered, Gril.gril,
                    Salt.salt, JustRight.justRight, GetInvite.getInvite, Ban.ban, Kick.kick, Prefix.prefix, AutoRole.autoRole, Announce.announce,
                    Broadcast.broadcast, Stats.stats, Google.google, Lmgtfy.lmgtfy, Bots.bots, Shutdown.shutdown, UrbanDictionary.UrbanDictionary,
                    Emojify.emojify, AllowedUsers.allowedUsers, CoinFlip.coinFlip, Roll.roll, ListServers.listServers, Strawpoll.strawpoll, Poll.poll,
                    Poll.vote, AddRole.addRole, RemoveRole.removeRole, Quote.quote, Support.support, Eval.eval, Byemom.byemom, Queue.queue,
                    Skip.skip, Playlist.playlist, Song.song, Stop.stop, Volume.volume, Host.host, Music.music, Pause.pause, VoteSkip.voteskip, Repeat.repeat, Invite.invite,
                    Erase.erase, Johnny.johnny, LongLive.longlive, BlockUser.blockUser, DELET.delet, AddPatron.addPatron, RemovePatron.removePatron,
                    Poosy.poosy, EightBall.eightBall, Pick.pick, GameCommand.game, ProfileCommand.profile, FullWidth.fullwidth, ShopCommand.shop, MyPlaylist.myPlaylist,
                    Rip.rip, RateWaifu.rateWaifu, Gabe.gabe, Changelog.changelog, LotteryCommand.lottery, Shuffle.shuffle, Balance.balanace, SlotMachine.slotMachine,
                    Pay.pay);
        }

        for (Action action : Action.values()) {
            List<String> responses = GSONUtils.getResponder(action).getResponses();
            KekBot.responses.put(action, responses);
        }
    }
}
 
開發者ID:Godson777,項目名稱:KekBot,代碼行數:49,代碼來源:KekBot.java


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