Search in sources :

Example 1 with GatewayDiscordClient

use of discord4j.core.GatewayDiscordClient in project symja_android_library by axkr.

the class SymjaBot method main.

public static void main(String[] args) {
    if (args.length > 0) {
        Locale.setDefault(Locale.US);
        ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS = true;
        ToggleFeature.COMPILE = false;
        Config.JAVA_UNSAFE = true;
        Config.SHORTEN_STRING_LENGTH = 512;
        Config.USE_VISJS = true;
        Config.FILESYSTEM_ENABLED = false;
        Config.FUZZY_PARSER = true;
        Config.UNPROTECT_ALLOWED = false;
        Config.USE_MANIPULATE_JS = true;
        Config.JAS_NO_THREADS = true;
        Config.MATHML_TRIG_LOWERCASE = false;
        Config.MAX_AST_SIZE = 10000;
        Config.MAX_OUTPUT_SIZE = 10000;
        Config.MAX_BIT_LENGTH = 200000;
        Config.MAX_POLYNOMIAL_DEGREE = 100;
        Config.MAX_INPUT_LEAVES = 100L;
        Config.MAX_MATRIX_DIMENSION_SIZE = 100;
        Config.PRIME_FACTORS = new BigIntegerPrimality();
        EvalEngine.get().setPackageMode(true);
        String theDiscordToken = args[0];
        GatewayDiscordClient client = DiscordClientBuilder.create(theDiscordToken).build().login().block();
        client.getEventDispatcher().on(ReadyEvent.class).subscribe(event -> {
            LocalDateTime now = LocalDateTime.now();
            final User self = event.getSelf();
            System.out.println(String.format(TIME_FORMATTER.format(now) + ": Logged in as %s#%s", self.getUsername(), self.getDiscriminator()));
        });
        client.on(MessageCreateEvent.class).subscribe(event -> {
            final Message message = event.getMessage();
            if (filterMessage(message)) {
                createMessage(message);
            }
        });
        client.onDisconnect().block();
    } else {
        System.out.println("The discord bot token has to be set as the first argument.");
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) ReadyEvent(discord4j.core.event.domain.lifecycle.ReadyEvent) MessageCreateEvent(discord4j.core.event.domain.message.MessageCreateEvent) User(discord4j.core.object.entity.User) Message(discord4j.core.object.entity.Message) BigIntegerPrimality(org.matheclipse.gpl.numbertheory.BigIntegerPrimality) GatewayDiscordClient(discord4j.core.GatewayDiscordClient)

Aggregations

GatewayDiscordClient (discord4j.core.GatewayDiscordClient)1 ReadyEvent (discord4j.core.event.domain.lifecycle.ReadyEvent)1 MessageCreateEvent (discord4j.core.event.domain.message.MessageCreateEvent)1 Message (discord4j.core.object.entity.Message)1 User (discord4j.core.object.entity.User)1 LocalDateTime (java.time.LocalDateTime)1 BigIntegerPrimality (org.matheclipse.gpl.numbertheory.BigIntegerPrimality)1