|
8 | 8 | using Microsoft.Extensions.Configuration; |
9 | 9 | using Microsoft.Extensions.DependencyInjection; |
10 | 10 | using Microsoft.Extensions.Logging; |
| 11 | +using Microsoft.Extensions.Options; |
11 | 12 |
|
12 | 13 | namespace DockerDiscordBot; |
13 | 14 |
|
@@ -38,11 +39,14 @@ private static IServiceCollection ConfigureServices(IServiceCollection services) |
38 | 39 | .AddOptions<ApplicationSettings>() |
39 | 40 | .Bind(_configuration.GetSection("ApplicationSettings")) |
40 | 41 | .Validate(x => |
41 | | - !string.IsNullOrWhiteSpace(x.DiscordToken), |
| 42 | + !string.IsNullOrWhiteSpace(x.DiscordToken), |
42 | 43 | "Discord token is required.") |
43 | 44 | .Validate(x => |
44 | | - !string.IsNullOrWhiteSpace(x.DockerHost), |
| 45 | + !string.IsNullOrWhiteSpace(x.DockerHost), |
45 | 46 | "Docker host is required.") |
| 47 | + .Validate(x => |
| 48 | + !string.IsNullOrWhiteSpace(x.CommandPrefix), |
| 49 | + "Command prefix is required.") |
46 | 50 | .ValidateOnStart(); |
47 | 51 |
|
48 | 52 | services.AddMediatR(config => |
@@ -81,6 +85,10 @@ private static async Task RunAsync() |
81 | 85 | var logger = _services.GetRequiredService<ILogger<Program>>(); |
82 | 86 | logger.LogInformation("Bot starting..."); |
83 | 87 |
|
| 88 | + var options = _services.GetRequiredService<IOptions<ApplicationSettings>>().Value; |
| 89 | + logger.LogInformation("Command prefix: {Prefix}", options.CommandPrefix); |
| 90 | + logger.LogInformation("Admin user: {User}", options.AdminUser); |
| 91 | + |
84 | 92 | var client = _services.GetRequiredService<IDiscordService>(); |
85 | 93 | await client.StartAsync(); |
86 | 94 |
|
|
0 commit comments