Search in sources :

Example 1 with Levelbot

use of de.kaktushose.levelbot.bot.Levelbot in project Levelbot by Kaktushose.

the class Bootstrapper method main.

public static void main(String[] args) throws LoginException, InterruptedException {
    long startTime = System.currentTimeMillis();
    log.info("Starting bot...");
    Thread.setDefaultUncaughtExceptionHandler((t, e) -> log.error("An unexpected error has occurred!", e));
    SpringApplication.run(Bootstrapper.class, args);
    levelbot = new Levelbot(Levelbot.GuildType.PRODUCTION);
    levelbot.start().indexMembers();
    startTime = System.currentTimeMillis() - startTime;
    log.info("Successfully started bot! Took {} seconds", TimeUnit.MILLISECONDS.toSeconds(startTime));
}
Also used : Levelbot(de.kaktushose.levelbot.bot.Levelbot)

Example 2 with Levelbot

use of de.kaktushose.levelbot.bot.Levelbot in project Levelbot by Kaktushose.

the class Statistics method getYoutubeStatistics.

private ChannelStatistics getYoutubeStatistics() throws IOException {
    HttpRequestInitializer httpRequestInitializer = request -> {
    };
    YouTube youTube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), httpRequestInitializer).setApplicationName("Levelbot").build();
    YouTube.Channels.List search = youTube.channels().list("statistics");
    search.setForUsername("nordrheintvplay");
    search.setKey(youtubeApiKey);
    ChannelListResponse response = search.execute();
    return response.getItems().get(0).getStatistics();
}
Also used : NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) OnlineStatus(net.dv8tion.jda.api.OnlineStatus) Logger(org.slf4j.Logger) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) LoggerFactory(org.slf4j.LoggerFactory) ChannelStatistics(com.google.api.services.youtube.model.ChannelStatistics) YouTube(com.google.api.services.youtube.YouTube) Levelbot(de.kaktushose.levelbot.bot.Levelbot) IOException(java.io.IOException) CompletableFuture(java.util.concurrent.CompletableFuture) Member(net.dv8tion.jda.api.entities.Member) Collectors(java.util.stream.Collectors) NumberFormat(java.text.NumberFormat) ChannelListResponse(com.google.api.services.youtube.model.ChannelListResponse) List(java.util.List) Guild(net.dv8tion.jda.api.entities.Guild) GatewayTask(net.dv8tion.jda.internal.utils.concurrent.task.GatewayTask) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer) Task(net.dv8tion.jda.api.utils.concurrent.Task) Locale(java.util.Locale) ChannelListResponse(com.google.api.services.youtube.model.ChannelListResponse) NetHttpTransport(com.google.api.client.http.javanet.NetHttpTransport) HttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory) YouTube(com.google.api.services.youtube.YouTube)

Aggregations

Levelbot (de.kaktushose.levelbot.bot.Levelbot)2 HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)1 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)1 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)1 YouTube (com.google.api.services.youtube.YouTube)1 ChannelListResponse (com.google.api.services.youtube.model.ChannelListResponse)1 ChannelStatistics (com.google.api.services.youtube.model.ChannelStatistics)1 IOException (java.io.IOException)1 NumberFormat (java.text.NumberFormat)1 List (java.util.List)1 Locale (java.util.Locale)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 OnlineStatus (net.dv8tion.jda.api.OnlineStatus)1 Guild (net.dv8tion.jda.api.entities.Guild)1 Member (net.dv8tion.jda.api.entities.Member)1 Task (net.dv8tion.jda.api.utils.concurrent.Task)1 GatewayTask (net.dv8tion.jda.internal.utils.concurrent.task.GatewayTask)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1