Small refactoring

This commit is contained in:
Toastie 2024-12-26 23:38:59 +13:00
parent 729e84fdce
commit b02aacadd6
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4

View file

@ -150,13 +150,14 @@ internal static class SupportChild
} }
Logger.Log("Setting up Discord client..."); Logger.Log("Setting up Discord client...");
DiscordClientBuilder clientBuilder = DiscordClientBuilder.CreateDefault(Config.token, DiscordIntents.All) DiscordClientBuilder clientBuilder = DiscordClientBuilder.CreateDefault(Config.token, DiscordIntents.All).SetReconnectOnFatalGatewayErrors();
.SetReconnectOnFatalGatewayErrors()
.ConfigureServices(configure => clientBuilder.ConfigureServices(configure =>
{ {
configure.AddSingleton<IClientErrorHandler>(new ErrorHandler()); configure.AddSingleton<IClientErrorHandler>(new ErrorHandler());
}) });
.ConfigureEventHandlers(builder =>
clientBuilder.ConfigureEventHandlers(builder =>
{ {
builder.HandleGuildDownloadCompleted(EventHandler.OnReady); builder.HandleGuildDownloadCompleted(EventHandler.OnReady);
builder.HandleGuildAvailable(EventHandler.OnGuildAvailable); builder.HandleGuildAvailable(EventHandler.OnGuildAvailable);
@ -164,14 +165,16 @@ internal static class SupportChild
builder.HandleGuildMemberAdded(EventHandler.OnMemberAdded); builder.HandleGuildMemberAdded(EventHandler.OnMemberAdded);
builder.HandleGuildMemberRemoved(EventHandler.OnMemberRemoved); builder.HandleGuildMemberRemoved(EventHandler.OnMemberRemoved);
builder.HandleComponentInteractionCreated(EventHandler.OnComponentInteractionCreated); builder.HandleComponentInteractionCreated(EventHandler.OnComponentInteractionCreated);
}) });
.UseInteractivity(new InteractivityConfiguration
clientBuilder.UseInteractivity(new InteractivityConfiguration
{ {
PaginationBehaviour = PaginationBehaviour.Ignore, PaginationBehaviour = PaginationBehaviour.Ignore,
PaginationDeletion = PaginationDeletion.DeleteMessage, PaginationDeletion = PaginationDeletion.DeleteMessage,
Timeout = TimeSpan.FromMinutes(15) Timeout = TimeSpan.FromMinutes(15)
}) });
.UseCommands((_, extension) =>
clientBuilder.UseCommands((_, extension) =>
{ {
extension.AddCommands( extension.AddCommands(
[ [
@ -203,7 +206,7 @@ internal static class SupportChild
typeof(ToggleActiveCommand), typeof(ToggleActiveCommand),
typeof(TranscriptCommand), typeof(TranscriptCommand),
typeof(UnassignCommand), typeof(UnassignCommand),
typeof(UnblacklistCommand) typeof(UnblacklistCommand),
]); ]);
extension.AddProcessor(new SlashCommandProcessor()); extension.AddProcessor(new SlashCommandProcessor());
extension.CommandErrored += EventHandler.OnCommandError; extension.CommandErrored += EventHandler.OnCommandError;
@ -211,13 +214,15 @@ internal static class SupportChild
{ {
RegisterDefaultCommandProcessors = false, RegisterDefaultCommandProcessors = false,
UseDefaultCommandErrorHandler = false UseDefaultCommandErrorHandler = false
}) });
.ConfigureExtraFeatures(clientConfig =>
clientBuilder.ConfigureExtraFeatures(clientConfig =>
{ {
clientConfig.LogUnknownEvents = false; clientConfig.LogUnknownEvents = false;
clientConfig.LogUnknownAuditlogs = false; clientConfig.LogUnknownAuditlogs = false;
}) });
.ConfigureLogging(config =>
clientBuilder.ConfigureLogging(config =>
{ {
config.AddProvider(new LogTestFactory()); config.AddProvider(new LogTestFactory());
}); });