1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-04 04:56:30 +03:00

Fix issues reported by ReSharper, implement GuildData (only GuildConfiguration)

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-05-30 18:42:57 +05:00
parent 3e9940f0ca
commit cca2965205
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
10 changed files with 201 additions and 116 deletions

View file

@ -1,3 +1,4 @@
using Boyfriend.Data.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -17,20 +18,11 @@ using Remora.Rest.Core;
namespace Boyfriend;
public class Boyfriend {
public static ILogger<Boyfriend> Logger = null!;
public static IConfiguration GuildConfiguration = null!;
public static readonly AllowedMentions NoMentions = new(
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());
public static async Task Main(string[] args) {
var host = CreateHostBuilder(args).UseConsoleLifetime().Build();
var services = host.Services;
Logger = services.GetRequiredService<ILogger<Boyfriend>>();
GuildConfiguration = services.GetRequiredService<IConfigurationBuilder>().AddJsonFile("guild_configs.json")
.Build();
await host.RunAsync();
}
@ -47,12 +39,10 @@ public class Boyfriend {
}
).ConfigureServices(
(_, services) => {
var responderTypes = typeof(Boyfriend).Assembly
.GetExportedTypes()
.Where(t => t.IsResponder());
foreach (var responderType in responderTypes) services.AddResponder(responderType);
services.AddDiscordCaching();
services.Configure<DiscordGatewayClientOptions>(
options => options.Intents |= GatewayIntents.MessageContents
| GatewayIntents.GuildMembers
| GatewayIntents.GuildScheduledEvents);
services.Configure<CacheSettings>(
settings => {
settings.SetDefaultAbsoluteExpiration(TimeSpan.FromHours(1));
@ -61,16 +51,16 @@ public class Boyfriend {
settings.SetSlidingExpiration<IMessage>(TimeSpan.FromDays(7));
});
services.AddTransient<IConfigurationBuilder, ConfigurationBuilder>();
services.Configure<DiscordGatewayClientOptions>(
options => options.Intents |= GatewayIntents.MessageContents
| GatewayIntents.GuildMembers
| GatewayIntents.GuildScheduledEvents);
services.AddDiscordCommands();
services.AddInteractivity();
services.AddInteractionGroup<InteractionResponders>();
services.AddTransient<IConfigurationBuilder, ConfigurationBuilder>()
.AddDiscordCaching()
.AddDiscordCommands()
.AddInteractivity()
.AddInteractionGroup<InteractionResponders>()
.AddSingleton<GuildDataService>();
var responderTypes = typeof(Boyfriend).Assembly
.GetExportedTypes()
.Where(t => t.IsResponder());
foreach (var responderType in responderTypes) services.AddResponder(responderType);
}
).ConfigureLogging(
c => c.AddConsole()