当前位置: 首页>>代码示例>>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;未经允许,请勿转载。