当前位置: 首页>>代码示例>>Java>>正文


Java JDABuilder.setAutoReconnect方法代码示例

本文整理汇总了Java中net.dv8tion.jda.core.JDABuilder.setAutoReconnect方法的典型用法代码示例。如果您正苦于以下问题:Java JDABuilder.setAutoReconnect方法的具体用法?Java JDABuilder.setAutoReconnect怎么用?Java JDABuilder.setAutoReconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.dv8tion.jda.core.JDABuilder的用法示例。


在下文中一共展示了JDABuilder.setAutoReconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
	}
}
 
开发者ID:BlackCraze,项目名称:GameResourceBot,代码行数:17,代码来源:Main.java

示例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();
}
 
开发者ID:gabixdev,项目名称:Kyoko,代码行数:48,代码来源:Kyoko.java

示例3: main

import net.dv8tion.jda.core.JDABuilder; //导入方法依赖的package包/类
public static final void main(String[] args) {
    try {
        Standard.setStarted(Instant.now());
        System.setOut(new SystemOutputStream(System.out, false));
        System.setErr(new SystemOutputStream(System.err, true));
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            //Standard.STANDARD_SETTINGS.saveSettings(); //FIXME WTF This is deleting the settings file all the time?!
            Standard.saveAllGuildSettings();
        }));
        Standard.JDA_SUPPLIER = () -> jda;
        NetworkUtil.init();
        reload();
        MySQL.init();
        builder = new JDABuilder(AccountType.BOT);
        builder.setAutoReconnect(true);
        //builder.setAudioSendFactory(null);
        builder.setStatus(OnlineStatus.ONLINE);
        builder.setGame(game = Game.of("Supreme-Bot"));
        initListeners();
        initCommands();
        init();
        initPlugins();
        loadAllGuilds();
        startJDA();
    } catch (Exception ex) {
        System.err.println("Main Error: " + ex);
        ex.printStackTrace();
    }
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:30,代码来源:SupremeBot.java


注:本文中的net.dv8tion.jda.core.JDABuilder.setAutoReconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。