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


Java AccountType類代碼示例

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


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

示例1: main

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
    //Code by ZekroTJA(github.com/ZekroTJA)
    StartArgumentHandler.args = args;
    //MY CODE
    builder = new JDABuilder(AccountType.BOT)
            .setToken(SECRETS.TOKEN)
            .setAudioEnabled(true)
            .setAutoReconnect(true)
            .setStatus(STATICS.STATUS)
            .setGame(Game.of(STATICS.CUSTOM_MESSAGE + " | _help | coded by Lee", "http://twitch.tv/lordleeyt"))
            ;

    initializeListeners();
    initializeCommands();
    SQL.connect();
    LVL.connect();


    try {
        builder.buildBlocking();
    } catch (InterruptedException | RateLimitedException | LoginException e) {
        e.printStackTrace();
    }

}
 
開發者ID:LeeDJD,項目名稱:Amme,代碼行數:26,代碼來源:Main.java

示例2: main

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
public static void main(String[] args) {
	try{
		new Database();
		OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder().readTimeout(60, TimeUnit.SECONDS).connectTimeout(60, TimeUnit.SECONDS).writeTimeout(60, TimeUnit.SECONDS);
		JDA jda = new JDABuilder(AccountType.BOT).setToken(Tokens.TOKEN).setHttpClientBuilder(httpBuilder).buildBlocking();
		jda.setAutoReconnect(true);
		jda.addEventListener(new EventHandler(jda));
	}catch(Exception ex){
		ex.printStackTrace();
	}
}
 
開發者ID:Implosions,項目名稱:BullyBot,代碼行數:12,代碼來源:Bot.java

示例3: start

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
public void start() throws RateLimitedException, InterruptedException, LoginException {
    this.discordAPI = new JDABuilder(AccountType.BOT)
                              .setToken(settings.getToken())
                              .setGame(new GameImpl(settings.getGame(), settings.getGameUrl(), settings.isTwitch() ? Game.GameType.TWITCH : Game.GameType.DEFAULT))
                              .addListener(new EventCaller(this))
                              .setAutoReconnect(true)
                              .setAudioEnabled(true)
                              .setBulkDeleteSplittingEnabled(false)
                              .buildBlocking();
    if (settings.getRedis().isEnabled()) {
        redisConnection.start();
        keepDataThread.start();
    }
    initCommands();
    initListeners();
}
 
開發者ID:kacperduras,項目名稱:Charrizard,代碼行數:17,代碼來源:Charrizard.java

示例4: initDiscord

import net.dv8tion.jda.core.AccountType; //導入依賴的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

示例5: setup

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
/**
 * Setup this bot.
 */
private void setup() {
    if (Configs.getMainConfig().getDiscordToken() == null) {
        Core.warn("Discord Token is not set, discord integrations will not function.");
        return;
    }

    try {
        bot = new JDABuilder(AccountType.BOT).setToken(Configs.getMainConfig().getDiscordToken())
                .addEventListener(this).setAutoReconnect(true).setGame(Game.of("Kineticraft"))
                .setStatus(OnlineStatus.ONLINE).buildAsync(); // Setup listener and connect to discord.
        active = true;
    } catch (Exception e) {
        e.printStackTrace();
        Core.warn("Failed to setup discord bot.");
    }
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:20,代碼來源:DiscordBot.java

示例6: start

import net.dv8tion.jda.core.AccountType; //導入依賴的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

示例7: loadDiscord

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
public void loadDiscord() {
	try {
		jda = new JDABuilder(AccountType.BOT)
				.setToken(DiscordBot.getInstance().getConfig().getToken())
				.addEventListener(new DiscordListener())
				.setAudioEnabled(true)
				.setBulkDeleteSplittingEnabled(false)
				.buildAsync();
		
		AudioSourceManagers.registerRemoteSources(getAudioPlayerManager());
		audioPlayer = getAudioPlayerManager().createPlayer();
		getAudioPlayer().setVolume(DiscordBot.getInstance().getConfig().getDefaultVolume());
		getAudioPlayer().addListener(new AudioListener());
		getDiscordThread().start();
		getCommand().registerCommands();
		LogHelper.info("Successfully loaded Discord.");
	} catch (LoginException | RateLimitedException | RuntimeException ex) {
		LogHelper.error("Exception loading Discord!");
		ex.printStackTrace();
	}
}
 
開發者ID:LXGaming,項目名稱:DiscordBot,代碼行數:22,代碼來源:Discord.java

示例8: postInit

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
public void postInit() {
	String token = getConfiguration().getToken();
	JDABuilder jdaBuilder = null;
	
	if (token != null && !token.equals("") && !token.equals("null")) {
		jdaBuilder = new JDABuilder(AccountType.BOT).setToken(token);
	}
	
	token = null;
	
	if (jdaBuilder == null) {
		getLogger().severe("Cannot start DiscordBot, No Token / Email and Password provided!");
		return;
	}
	
	try {
		jda = jdaBuilder
				.addEventListener(new BotListener())
				.setAudioEnabled(false)
				.setBulkDeleteSplittingEnabled(false)
				.buildAsync();
	} catch (IllegalArgumentException | LoginException | RateLimitedException ex) {
		getLogger().severe("Connection Failed! Invalid BotToken");
		ex.printStackTrace();
	}
}
 
開發者ID:LXGaming,項目名稱:DiscordBot,代碼行數:27,代碼來源:DiscordBotCore.java

示例9: initJda

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
/**
 * Starts JDA.
 *
 * @return {@code true} if everything went well, {@code false} otherwise.
 */
private boolean initJda() {

    try {
        SimpleLog.Level level = JDAImpl.LOG.getLevel();
        SimpleLog.Level socketLevel = WebSocketClient.LOG.getLevel();
        JDAImpl.LOG.setLevel(SimpleLog.Level.OFF);
        WebSocketClient.LOG.setLevel(SimpleLog.Level.OFF);

        jda = new JDABuilder(AccountType.BOT).setToken(botToken).buildBlocking();
        jda.getPresence().setGame(Game.of("2.0.2"));
        logger.writeFrom("jda", "Successfully connected!");
        logger.writeFrom("jda WebSocket", "Connected to WebSocket!");

        JDAImpl.LOG.setLevel(level);
        WebSocketClient.LOG.setLevel(socketLevel);
    } catch (LoginException | InterruptedException | RateLimitedException e) {
        logger.writeFrom("jda", "Couldn't connect!");
        e.printStackTrace();
        return false;
    }
    return true;
}
 
開發者ID:iSach,項目名稱:Samaritan,代碼行數:28,代碼來源:Samaritan.java

示例10: createMessage

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
public Message createMessage(JSONObject jsonObject, boolean exceptionOnMissingUser)
{
    final long channelId = jsonObject.getLong("channel_id");

    MessageChannel chan = api.getTextChannelById(channelId);
    if (chan == null)
        chan = api.getPrivateChannelById(channelId);
    if (chan == null)
        chan = api.getFakePrivateChannelMap().get(channelId);
    if (chan == null && api.getAccountType() == AccountType.CLIENT)
        chan = api.asClient().getGroupById(channelId);
    if (chan == null)
        throw new IllegalArgumentException(MISSING_CHANNEL);

    return createMessage(jsonObject, chan, exceptionOnMissingUser);
}
 
開發者ID:DV8FromTheWorld,項目名稱:JDA,代碼行數:17,代碼來源:EntityBuilder.java

示例11: main

import net.dv8tion.jda.core.AccountType; //導入依賴的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

示例12: restartJDA

import net.dv8tion.jda.core.AccountType; //導入依賴的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();
}
 
開發者ID:Mantaro,項目名稱:MantaroRPG,代碼行數:21,代碼來源:MantaroShard.java

示例13: onMessageReceived

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
@Override
public void onMessageReceived(MessageReceivedEvent event) {
    if (event.getMessage().getRawContent().startsWith(jba.getPrefix(event.getGuild())) &&
            (jba.getClient().getAccountType() == AccountType.BOT && !event.getAuthor().isBot() || jba.getClient().getAccountType() == AccountType.CLIENT && event.getMessage()
            .getAuthor().getId().equals(jba.getClient().getSelfUser().getId()))) {
        String message = event.getMessage().getRawContent();
        String command = message.replaceFirst(Pattern.quote(jba.getPrefix(event.getGuild())), "");
        String[] args = new String[0];
        if (message.contains(" ")) {
            command = command.substring(0, command.indexOf(" "));

            args = message.substring(message.indexOf(" ") + 1).split(" ");
        }
        for (Command cmd : jba.getCommands()) {
            if (cmd.getCommand().equalsIgnoreCase(command)) {
                execute(cmd, args, event);
                return;
            } else {
                for (String alias : cmd.getAliases()) {
                    if (alias.equalsIgnoreCase(command)) {
                        execute(cmd, args, event);
                        return;
                    }
                }
            }
        }
    }
}
 
開發者ID:WalshyDev,項目名稱:JBA,代碼行數:29,代碼來源:JBAListener.java

示例14: init

import net.dv8tion.jda.core.AccountType; //導入依賴的package包/類
public void init(){
    // This is the new config system, here you make a JSON file which you can hold a bunch of configurable values.
    // In this case we are using it to store token and prefix.
    // The parameter for Config is the config name (If it doesn't have a .json extension it will be added itself!)
    config = new Config("config");
    // This is your account type so AccountType.BOT or AccountType.CLIENT
    // Then pass your bot/client token
    // Third argument is the command prefix. You can chose to not include this for no command system.
    super.init(AccountType.BOT, config.getString("token"), config.getString("prefix"));
}
 
開發者ID:WalshyDev,項目名稱:JBA,代碼行數:11,代碼來源:ExampleBot.java

示例15: initJDA

import net.dv8tion.jda.core.AccountType; //導入依賴的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();
    }
 
開發者ID:Rubicon-Bot,項目名稱:Rubicon,代碼行數:30,代碼來源:RubiconBot.java


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