Skip to content

Commit

Permalink
fix: Sharding sample inaccurate (#2408)
Browse files Browse the repository at this point in the history
  • Loading branch information
csmir committed Aug 1, 2022
1 parent 902326d commit 519deda
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions samples/ShardedClient/Services/InteractionHandlingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public InteractionHandlingService(IServiceProvider services)

_service.Log += LogAsync;
_client.InteractionCreated += OnInteractionAsync;
_client.ShardReady += ReadyAsync;
// For examples on how to handle post execution,
// see the InteractionFramework samples.
}
Expand All @@ -30,11 +31,6 @@ public InteractionHandlingService(IServiceProvider services)
public async Task InitializeAsync()
{
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)
Expand All @@ -53,5 +49,14 @@ private Task LogAsync(LogMessage log)

return Task.CompletedTask;
}

private async Task ReadyAsync(DiscordSocketClient _)
{
#if DEBUG
await _service.RegisterCommandsToGuildAsync(1 /* implement */);
#else
await _service.RegisterCommandsGloballyAsync();
#endif
}
}
}

0 comments on commit 519deda

Please sign in to comment.