Skip to content

Commit e495438

Browse files
committed
fix: use client, not shard for example
1 parent fe0e855 commit e495438

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

ApplicationCommands/src/Program.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static async Task MainAsync(string[] args)
5252
LoggerFactory = new LoggerFactory().AddSerilog(Log.Logger)
5353
};
5454

55-
DiscordShardedClient discordShardedClient = new(discordConfiguration);
55+
DiscordClient discordClient = new(discordConfiguration);
5656

5757
ApplicationCommandsConfiguration appCommandsConfiguration = new(new ServiceCollection()
5858
.AddSingleton(Random.Shared)
@@ -62,26 +62,23 @@ public static async Task MainAsync(string[] args)
6262
DebugStartup = true
6363
};
6464

65-
discordShardedClient.Logger.LogInformation("Registering application commands...");
65+
discordClient.Logger.LogInformation("Registering application commands...");
6666

6767
var guildId = ResolveGuildId(args);
6868

69-
foreach (var discordClient in discordShardedClient.ShardClients.Values)
70-
{
71-
var appCommandShardExtension = discordClient.UseApplicationCommands(appCommandsConfiguration);
69+
var appCommandExtension = discordClient.UseApplicationCommands(appCommandsConfiguration);
7270

73-
appCommandShardExtension.SlashCommandExecuted += Slash_SlashCommandExecutedAsync;
74-
appCommandShardExtension.SlashCommandErrored += Slash_SlashCommandErroredAsync;
75-
appCommandShardExtension.ContextMenuExecuted += Context_ContextMenuCommandExecutedAsync;
76-
appCommandShardExtension.ContextMenuErrored += Context_ContextMenuCommandErroredAsync;
71+
appCommandExtension.SlashCommandExecuted += Slash_SlashCommandExecutedAsync;
72+
appCommandExtension.SlashCommandErrored += Slash_SlashCommandErroredAsync;
73+
appCommandExtension.ContextMenuExecuted += Context_ContextMenuCommandExecutedAsync;
74+
appCommandExtension.ContextMenuErrored += Context_ContextMenuCommandErroredAsync;
7775

78-
if (guildId != null)
79-
appCommandShardExtension.RegisterGuildCommands(Assembly.GetExecutingAssembly(), (ulong)guildId);
80-
else
81-
appCommandShardExtension.RegisterGlobalCommands(Assembly.GetExecutingAssembly());
82-
}
76+
if (guildId != null)
77+
appCommandExtension.RegisterGuildCommands(Assembly.GetExecutingAssembly(), (ulong)guildId);
78+
else
79+
appCommandExtension.RegisterGlobalCommands(Assembly.GetExecutingAssembly());
8380

84-
discordShardedClient.Logger.LogInformation("Application commands registered successfully");
81+
discordClient.Logger.LogInformation("Application commands registered successfully");
8582

8683
using var shutdown = new CancellationTokenSource();
8784
Console.CancelKeyPress += (_, eventArgs) =>
@@ -91,9 +88,9 @@ public static async Task MainAsync(string[] args)
9188
};
9289

9390
Log.Logger.Information("Connecting to Discord...");
94-
await discordShardedClient.StartAsync();
91+
await discordClient.ConnectAsync();
9592

96-
discordShardedClient.Logger.LogInformation("Connection success! Logged in as {UsernameWithDiscriminator} ({CurrentUserId})", discordShardedClient.CurrentUser.UsernameWithDiscriminator, discordShardedClient.CurrentUser.Id);
93+
discordClient.Logger.LogInformation("Connection success! Logged in as {UsernameWithDiscriminator} ({CurrentUserId})", discordClient.CurrentUser.UsernameWithDiscriminator, discordClient.CurrentUser.Id);
9794

9895
try
9996
{
@@ -103,7 +100,7 @@ public static async Task MainAsync(string[] args)
103100
{ }
104101
finally
105102
{
106-
await discordShardedClient.StopAsync();
103+
await discordClient.DisconnectAsync();
107104
Log.CloseAndFlush();
108105
}
109106
}

0 commit comments

Comments
 (0)