reafactoring

This commit is contained in:
2023-08-04 23:19:31 -03:00
parent 1ea940e03e
commit 73b0bac359
6 changed files with 82 additions and 66 deletions

View File

@@ -11,6 +11,7 @@ namespace TextCommandFramework
class Program
{
private static string TOKEN = Environment.GetEnvironmentVariable("TOKEN");
private static int SHARDS = int.Parse(Environment.GetEnvironmentVariable("SHARDS"));
static void Main(string[] args)
{
@@ -18,8 +19,16 @@ namespace TextCommandFramework
{
throw new Exception("Discord Bot Token was not found.");
}
if (SHARDS == 0)
{
Console.WriteLine("Shards amount not found, defaulting to 1.");
SHARDS = 1;
}
new Program().MainAsync().GetAwaiter().GetResult();
new Program()
.MainAsync()
.GetAwaiter()
.GetResult();
}
public async Task MainAsync()
@@ -84,7 +93,7 @@ namespace TextCommandFramework
.AddSingleton(new DiscordSocketConfig
{
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent,
TotalShards = 3
TotalShards = SHARDS
})
.AddSingleton<DiscordShardedClient>()
.AddSingleton<CommandService>()