Search in sources :

Example 1 with Test

use of com.freya02.botcommands.api.application.annotations.Test 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 Test

use of com.freya02.botcommands.api.application.annotations.Test in project BotCommands by freya022.

the class CtorInjMain method alt2.

private static void alt2(JDA jda) throws IOException {
    // Just a test value
    Connection connection = null;
    CommandsBuilder.newBuilder().extensionsBuilder(extensionsBuilder -> extensionsBuilder.registerInstanceSupplier(SlashCtorInjectionTest.class, context -> new SlashCtorInjectionTest(context, connection))).build(jda, "com.freya02.bot.wiki.ctorinj.commands");
}
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) IOException(java.io.IOException) SlashCtorInjectionTest(com.freya02.bot.wiki.ctorinj.commands.SlashCtorInjectionTest) Connection(java.sql.Connection) SlashCtorInjectionTest(com.freya02.bot.wiki.ctorinj.commands.SlashCtorInjectionTest)

Example 3 with Test

use of com.freya02.botcommands.api.application.annotations.Test in project BotCommands by freya022.

the class CtorInjMain method alt1.

private static void alt1(JDA jda) throws IOException {
    // Just a test value
    Connection connection = null;
    CommandsBuilder.newBuilder().extensionsBuilder(extensionsBuilder -> extensionsBuilder.registerConstructorParameter(Connection.class, ignored -> connection)).build(jda, "com.freya02.bot.wiki.ctorinj.commands");
}
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) IOException(java.io.IOException) SlashCtorInjectionTest(com.freya02.bot.wiki.ctorinj.commands.SlashCtorInjectionTest) Connection(java.sql.Connection)

Example 4 with Test

use of com.freya02.botcommands.api.application.annotations.Test in project BotCommands by freya022.

the class AnnotationUtils method getEffectiveTestGuildIds.

public static TLongSet getEffectiveTestGuildIds(BContext context, Method method) {
    TLongSet testIds = new TLongHashSet(context.getTestGuildIds());
    final List<Test> effectiveAnnotations = getEffectiveAnnotations(method, Test.class);
    for (Test test : effectiveAnnotations) {
        final long[] ids = test.guildIds();
        final AppendMode mode = test.mode();
        if (mode == AppendMode.SET) {
            testIds.clear();
            testIds.addAll(ids);
            return testIds;
        } else if (mode == AppendMode.ADD) {
            testIds.addAll(ids);
        }
    }
    return testIds;
}
Also used : Test(com.freya02.botcommands.api.application.annotations.Test) TLongSet(gnu.trove.set.TLongSet) TLongHashSet(gnu.trove.set.hash.TLongHashSet)

Aggregations

Config (com.freya02.bot.Config)3 CommandsBuilder (com.freya02.botcommands.api.CommandsBuilder)3 Connection (java.sql.Connection)3 JDA (net.dv8tion.jda.api.JDA)3 JDABuilder (net.dv8tion.jda.api.JDABuilder)3 SlashCtorInjectionTest (com.freya02.bot.wiki.ctorinj.commands.SlashCtorInjectionTest)2 IOException (java.io.IOException)2 Test (com.freya02.botcommands.api.application.annotations.Test)1 TLongSet (gnu.trove.set.TLongSet)1 TLongHashSet (gnu.trove.set.hash.TLongHashSet)1