本文整理汇总了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!");
}
示例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);
}
}
}