Browse Source

fix: Sharding sample inaccurate (#2408)

tags/3.8.0
Armano den Boef GitHub 2 years ago
parent
commit
519deda6e7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions
  1. +10
    -5
      samples/ShardedClient/Services/InteractionHandlingService.cs

+ 10
- 5
samples/ShardedClient/Services/InteractionHandlingService.cs 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
}
} }
} }

Loading…
Cancel
Save