Search in sources :

Example 1 with Config

use of com.freya02.bot.Config in project BotCommands by freya022.

the class FieldInjMain method main.

public static void main(String[] args) {
    try {
        final Config config = Config.readConfig();
        final JDA jda = JDABuilder.createLight(config.getToken()).build().awaitReady();
        // Just a test value
        Connection connection = null;
        CommandsBuilder.newBuilder().extensionsBuilder(extensionsBuilder -> extensionsBuilder.registerCommandDependency(Connection.class, () -> connection)).build(jda, "com.freya02.bot.wiki.fieldinj.commands");
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : Config(com.freya02.bot.Config) CommandsBuilder(com.freya02.botcommands.api.CommandsBuilder) JDA(net.dv8tion.jda.api.JDA) Connection(java.sql.Connection) JDABuilder(net.dv8tion.jda.api.JDABuilder) Config(com.freya02.bot.Config) JDA(net.dv8tion.jda.api.JDA) Connection(java.sql.Connection)

Example 2 with Config

use of com.freya02.bot.Config in project BotCommands by freya022.

the class InstanceSupplierMain method main.

public static void main(String[] args) {
    try {
        final Config config = Config.readConfig();
        final JDA jda = JDABuilder.createLight(config.getToken()).build().awaitReady();
        CommandsBuilder.newBuilder().extensionsBuilder(extensionsBuilder -> extensionsBuilder.registerInstanceSupplier(SlashInstanceSupplierTest.class, ignored -> new SlashInstanceSupplierTest(new SlashInstanceSupplierTest.Dummy()))).build(jda, "com.freya02.bot.wiki.instancesupplier.commands");
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : Config(com.freya02.bot.Config) CommandsBuilder(com.freya02.botcommands.api.CommandsBuilder) JDA(net.dv8tion.jda.api.JDA) JDABuilder(net.dv8tion.jda.api.JDABuilder) SlashInstanceSupplierTest(com.freya02.bot.wiki.instancesupplier.commands.SlashInstanceSupplierTest) Config(com.freya02.bot.Config) JDA(net.dv8tion.jda.api.JDA) SlashInstanceSupplierTest(com.freya02.bot.wiki.instancesupplier.commands.SlashInstanceSupplierTest)

Example 3 with Config

use of com.freya02.bot.Config in project BotCommands by freya022.

the class CondInstMain method main.

public static void main(String[] args) {
    try {
        final Config config = Config.readConfig();
        final JDA jda = JDABuilder.createLight(config.getToken()).build().awaitReady();
        CommandsBuilder.newBuilder().build(jda, "com.freya02.bot.wiki.condinst.commands");
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : Config(com.freya02.bot.Config) JDA(net.dv8tion.jda.api.JDA)

Example 4 with Config

use of com.freya02.bot.Config in project BotCommands by freya022.

the class Main method main.

public static void main(String[] args) {
    try {
        // Make sure that the file Config.json exists under src/main/java/resources/com/freya02/bot/Config.json and has a valid token inside
        final Config config = Config.readConfig();
        // Set up JDA
        final JDA jda = JDABuilder.createLight(config.getToken()).setActivity(Activity.playing("Prefix is " + config.getPrefix())).build().awaitReady();
        // Print some information about the bot
        LOGGER.info("Bot connected as {}", jda.getSelfUser().getAsTag());
        LOGGER.info("The bot is present on these guilds :");
        for (Guild guild : jda.getGuildCache()) {
            LOGGER.info("\t- {} ({})", guild.getName(), guild.getId());
        }
        // Instantiate the database needed for components
        final ComponentsDB componentsDB = new ComponentsDB(config);
        // Build the command framework:
        // Prefix: configured in Config.json
        // Owner: configured in Config.json
        // Commands package: com.freya02.bot.commands
        CommandsBuilder.newBuilder(config.getOwnerId()).textCommandBuilder(textCommandsBuilder -> textCommandsBuilder.addPrefix(config.getPrefix())).setComponentManager(new DefaultComponentManager(componentsDB::getConnection)).build(jda, // Registering listeners is taken care of by the lib
        "com.freya02.bot.commands");
    } catch (IOException | InterruptedException | LoginException | SQLException e) {
        LOGGER.error("Unable to start the bot", e);
        System.exit(-1);
    }
}
Also used : SQLException(java.sql.SQLException) JDA(net.dv8tion.jda.api.JDA) LoginException(javax.security.auth.login.LoginException) IOException(java.io.IOException) Guild(net.dv8tion.jda.api.entities.Guild) DefaultComponentManager(com.freya02.botcommands.api.components.DefaultComponentManager)

Example 5 with Config

use of com.freya02.bot.Config in project BotCommands by freya022.

the class CtorInjMain method main.

public static void main(String[] args) {
    try {
        final Config config = Config.readConfig();
        final JDA jda = JDABuilder.createLight(config.getToken()).build().awaitReady();
        // alt1(jda);
        alt2(jda);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : Config(com.freya02.bot.Config) JDA(net.dv8tion.jda.api.JDA) IOException(java.io.IOException)

Aggregations

JDA (net.dv8tion.jda.api.JDA)11 Config (com.freya02.bot.Config)9 CommandsBuilder (com.freya02.botcommands.api.CommandsBuilder)5 JDABuilder (net.dv8tion.jda.api.JDABuilder)4 DefaultComponentManager (com.freya02.botcommands.api.components.DefaultComponentManager)2 IOException (java.io.IOException)2 SlashInstanceSupplierTest (com.freya02.bot.wiki.instancesupplier.commands.SlashInstanceSupplierTest)1 Logging (com.freya02.botcommands.api.Logging)1 CommandPath (com.freya02.botcommands.api.application.CommandPath)1 KotlinMethodRunnerFactory (com.freya02.botcommands.api.runner.KotlinMethodRunnerFactory)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 LocalDateTime (java.time.LocalDateTime)1 LoginException (javax.security.auth.login.LoginException)1 Activity (net.dv8tion.jda.api.entities.Activity)1 Guild (net.dv8tion.jda.api.entities.Guild)1 GatewayIntent (net.dv8tion.jda.api.requests.GatewayIntent)1 Nullable (org.jetbrains.annotations.Nullable)1 Logger (org.slf4j.Logger)1