Exemplo n.º 1
0
 public PubgApi(string apiKey)
 {
     PubgApiConfiguration.Configure(opt =>
     {
         opt.ApiKey = apiKey;
     });
 }
Exemplo n.º 2
0
 // Discord.Net heavily utilizes TAP for async, so we create
 // an asynchronous context from the beginning.
 static void Main(string[] args)
 {
     PubgApiConfiguration.Configure(opt =>
     {
         opt.ApiKey = Credentials.PubgToken;
     });
     new Program()
     .MainAsync()
     .GetAwaiter()
     .GetResult();
 }
Exemplo n.º 3
0
        public void Load()
        {
            // the api key is not empty, we already have it
            if (Settings.PubgApiKey == string.Empty)
            {
                Settings.PubgApiKey = ResourceManifestReader.ReadText("keys.pubgapi.txt");
            }

            PubgApiConfiguration.Configure(opt =>
            {
                opt.ApiKey = Settings.PubgApiKey;
            });
        }
Exemplo n.º 4
0
        public async Task MainAsync()
        {
            var config = Configuration.Create();
            var bot    = new DiscordBot();

            bot.LoginAndStartAsync();

            PubgApiConfiguration.Configure(opt =>
            {
                opt.ApiKey = config.pubgToken;
            });

            await Task.Delay(-1);
        }
Exemplo n.º 5
0
        public Configure()
        {
            PubgApiConfiguration.Configure(opt =>
            {
                opt.ApiKey = Config.PubgToken;
            });

            using (var con = new PubgDB())
            {
                if (!con.Database.GetService <IRelationalDatabaseCreator>().Exists())
                {
                    // Create the Db if it doesn't exist and applies any pending migration.
                    con.Database.Migrate();
                }
            }
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            PubgApiConfiguration
            .Configure(opt => opt.ApiKey = Configuration["PubgApiKey"]);

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });
        }
Exemplo n.º 7
0
        public async Task RunAsync()
        {
            IServiceCollection services = new ServiceCollection()
                                          .AddSingleton(_client)
                                          .AddSingleton(_credentials)
                                          .AddSingleton <CommandService>()
                                          .AddSingleton <CommandHandler>()
                                          .AddSingleton <GuildHandler>()
                                          .AddSingleton <AudioService>()
                                          .AddSingleton <MemesService>()
                                          .AddSingleton <DrawService>()
                                          .AddSingleton <GamesService>()
                                          .AddSingleton <GeneralService>()
                                          .AddSingleton <ImgurService>()
                                          .AddSingleton <ModerationService>()
                                          .AddSingleton <MoneyService>()
                                          .AddSingleton <NewsService>()
                                          .AddSingleton <PubgService>()
                                          .AddSingleton <ShortenService>()
                                          .AddSingleton <UserService>()
                                          .AddSingleton <UtilityService>()
                                          .AddSingleton <YouTubeService>()
                                          .AddSingleton <SpotifyWebAPI>()
                                          .AddSingleton <SpotifyService>()
                                          .AddSingleton <PlaylistService>()
                                          .AddSingleton <PokemonService>()
                                          .AddSingleton <HelpService>()
                                          .AddSingleton <IPokemonRepository, DatabasePokemonRepository>()
                                          .AddSingleton <IPlaylistRepository, DatabasePlaylistRepository>()
                                          .AddSingleton <IMoneyRepository, DatabaseMoneyRepository>()
                                          .AddSingleton <IGuildRepository, DatabaseGuildRepository>();

            services.AddSingleton(new Reddit(new RefreshTokenWebAgent(
                                                 _credentials.RedditRefreshToken,
                                                 _credentials.RedditClientId,
                                                 _credentials.RedditClientSecret,
                                                 _credentials.RedditRedirectUri)));

            PubgApiConfiguration.Configure(config => config.ApiKey = _credentials.PUBGApiKey);

            IServiceProvider provider = services.BuildServiceProvider();

            await provider.GetRequiredService <CommandHandler>().InitializeAsync(provider);

            try
            {
                await _client.LoginAsync(TokenType.Bot, _credentials.Token);
            }
            catch (HttpException e)
            {
                await Logger.Log("Failed to log in", e, LogSeverity.Critical);

                Console.ReadLine();
                Environment.Exit(0);
            }

            await _client.StartAsync();

            await _client.SetStatusAsync(UserStatus.Online);

            await Task.Delay(-1, _appCancellationToken);
        }