コード例 #1
0
ファイル: Startup.cs プロジェクト: tuansan/BotNina
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDiscordClient discordClient)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Bot Nina is alive!");

                if (!discordClient.IsRunning)
                {
                    // You can add the token as an environment variable - e.g. as a Config Var in Heroku
                    string discordToken = Environment.GetEnvironmentVariable("DiscordToken");
                    await discordClient.RunBot(app.ApplicationServices, Configuration, discordToken);
                }
            });
        }