fix: Sharding sample inaccurate (#2408)

This commit is contained in:
Armano den Boef
2022-08-01 21:46:27 +02:00
committed by GitHub
parent 902326d1f3
commit 519deda6e7

View File

@@ -22,6 +22,7 @@ namespace ShardedClient.Services
_service.Log += LogAsync; _service.Log += LogAsync;
_client.InteractionCreated += OnInteractionAsync; _client.InteractionCreated += OnInteractionAsync;
_client.ShardReady += ReadyAsync;
// For examples on how to handle post execution, // For examples on how to handle post execution,
// see the InteractionFramework samples. // see the InteractionFramework samples.
} }
@@ -30,11 +31,6 @@ namespace ShardedClient.Services
public async Task InitializeAsync() public async Task InitializeAsync()
{ {
await _service.AddModulesAsync(typeof(InteractionHandlingService).Assembly, _provider); await _service.AddModulesAsync(typeof(InteractionHandlingService).Assembly, _provider);
#if DEBUG
await _service.RegisterCommandsToGuildAsync(1 /* implement */);
#else
await _service.RegisterCommandsGloballyAsync();
#endif
} }
private async Task OnInteractionAsync(SocketInteraction interaction) private async Task OnInteractionAsync(SocketInteraction interaction)
@@ -53,5 +49,14 @@ namespace ShardedClient.Services
return Task.CompletedTask; return Task.CompletedTask;
} }
private async Task ReadyAsync(DiscordSocketClient _)
{
#if DEBUG
await _service.RegisterCommandsToGuildAsync(1 /* implement */);
#else
await _service.RegisterCommandsGloballyAsync();
#endif
}
} }
} }