本文整理汇总了Java中net.dv8tion.jda.core.JDABuilder.buildBlocking方法的典型用法代码示例。如果您正苦于以下问题:Java JDABuilder.buildBlocking方法的具体用法?Java JDABuilder.buildBlocking怎么用?Java JDABuilder.buildBlocking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.JDABuilder
的用法示例。
在下文中一共展示了JDABuilder.buildBlocking方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDiscord
import net.dv8tion.jda.core.JDABuilder; //导入方法依赖的package包/类
private static void initDiscord() {
JDABuilder builder = new JDABuilder(AccountType.BOT);
try {
builder.setToken(BotConfig.DISCORD_TOKEN);
builder.setAutoReconnect(true);
builder.setStatus(OnlineStatus.ONLINE);
builder.addEventListener(new ReadyListener());
builder.addEventListener(new MessageListener());
builder.buildBlocking();
} catch (Throwable e) {
e.printStackTrace();
} finally {
builder.setStatus(OnlineStatus.OFFLINE);
}
}
示例2: start
import net.dv8tion.jda.core.JDABuilder; //导入方法依赖的package包/类
public void start() throws LoginException, InterruptedException, RateLimitedException {
running = true;
// init logger
AnsiConsole.systemInstall();
log = Logger.getLogger("Kyoko");
log.setUseParentHandlers(false);
ColoredFormatter formatter = new ColoredFormatter();
ConsoleHandler handler = new ConsoleHandler();
handler.setFormatter(formatter);
log.addHandler(handler);
log.info("Kyoko v" + Constants.VERSION + " is starting...");
i18n.loadMessages();
JDABuilder builder = new JDABuilder(AccountType.BOT);
if (settings.getToken() != null) {
if (settings.getToken().equalsIgnoreCase("Change me")) {
System.out.println("No token specified, please set it in config.json");
System.exit(1);
}
builder.setToken(settings.getToken());
}
boolean gameEnabled = false;
if (settings.getGame() != null && !settings.getGame().isEmpty()) {
gameEnabled = true;
builder.setGame(Game.of("booting..."));
}
builder.setAutoReconnect(true);
builder.setBulkDeleteSplittingEnabled(false);
builder.addEventListener(eventHandler);
builder.setAudioEnabled(true);
builder.setStatus(OnlineStatus.IDLE);
jda = builder.buildBlocking();
log.info("Invite link: " + "https://discordapp.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&scope=bot&permissions=" + Constants.PERMISSIONS);
if (gameEnabled) {
Thread t = new Thread(new Kyoko.BlinkThread());
t.start();
}
registerCommands();
}
示例3: restartJDA
import net.dv8tion.jda.core.JDABuilder; //导入方法依赖的package包/类
public void restartJDA(boolean force) throws RateLimitedException, LoginException, InterruptedException {
if (jda != null) {
log.info("Attempting to drop shard #" + shardId);
if (!force) prepareShutdown();
jda.shutdown(false);
log.info("Dropped shard #" + shardId);
}
JDABuilder jdaBuilder = new JDABuilder(AccountType.BOT)
.setToken(config().get().token)
.setEventManager(manager)
.setAutoReconnect(true)
.setCorePoolSize(15)
.setGame(Game.of("Hold on to your seatbelts!"));
if (totalShards > 1)
jdaBuilder.useSharding(shardId, totalShards);
jda = jdaBuilder.buildBlocking();
readdListeners();
}
示例4: initJDA
import net.dv8tion.jda.core.JDABuilder; //导入方法依赖的package包/类
/**
* Initializes the JDA instance.
*/
public static void initJDA() {
if (instance == null)
throw new NullPointerException("RubiconBot has not been initialized yet.");
JDABuilder builder = new JDABuilder(AccountType.BOT);
builder.setToken(instance.configuration.getString("token"));
builder.setGame(Game.playing("Starting...."));
// add all EventListeners
for (EventListener listener : instance.eventListeners)
builder.addEventListener(listener);
new ListenerManager(builder);
try {
instance.jda = builder.buildBlocking();
} catch (LoginException | InterruptedException e) {
Logger.error(e.getMessage());
}
CommandVote.loadPolls(instance.jda);
Info.lastRestart = new Date();
// CommandGiveaway.startGiveawayManager(instance.jda);
getJDA().getPresence().setGame(Game.playing("Started."));
GameAnimator.start();
}