Greatly reduce code complexity & make IF samples functional (#2205)

* Greatly reduce code complexity

* Fixes sharded client IF implementation
This commit is contained in:
Armano den Boef
2022-03-26 13:37:30 +01:00
committed by GitHub
parent c286b9978e
commit 47de5a2fb4
12 changed files with 170 additions and 351 deletions

View File

@@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace ShardedClient.Modules
{
// A display of portability, which shows how minimal the difference between the 2 frameworks is.
public class InteractionModule : InteractionModuleBase<ShardedInteractionContext<SocketSlashCommand>>
public class InteractionModule : InteractionModuleBase<ShardedInteractionContext>
{
[SlashCommand("info", "Information about this shard.")]
public async Task InfoAsync()

View File

@@ -45,8 +45,11 @@ namespace ShardedClient
client.ShardReady += ReadyAsync;
client.Log += LogAsync;
await services.GetRequiredService<InteractionHandlingService>().InitializeAsync();
await services.GetRequiredService<CommandHandlingService>().InitializeAsync();
await services.GetRequiredService<InteractionHandlingService>()
.InitializeAsync();
await services.GetRequiredService<CommandHandlingService>()
.InitializeAsync();
// Tokens should be considered secret data, and never hard-coded.
await client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("token"));

View File

@@ -31,9 +31,9 @@ namespace ShardedClient.Services
{
await _service.AddModulesAsync(typeof(InteractionHandlingService).Assembly, _provider);
#if DEBUG
await _service.AddCommandsToGuildAsync(_client.Guilds.First(x => x.Id == 1));
await _service.RegisterCommandsToGuildAsync(1 /* implement */);
#else
await _service.AddCommandsGloballyAsync();
await _service.RegisterCommandsGloballyAsync();
#endif
}