-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
90 lines (75 loc) · 3.03 KB
/
Copy pathProgram.cs
File metadata and controls
90 lines (75 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using NetCord.Gateway;
using NetCord.Hosting.Gateway;
using NetCord.Hosting.Services;
using NetCord.Hosting.Services.ApplicationCommands;
using Npgsql;
namespace Polyester;
class Program
{
public static readonly NpgsqlDataSource npgDataSource;
public static readonly Dictionary<ClothingItem, int> ClothingItemWeightMap;
public static readonly Dictionary<ClothingItem, int> ClothingItemDefaultPercentageMap;
static Program()
{
IConfigurationRoot config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
DatabaseAppSettings? dbConfig = config.GetRequiredSection("Database").Get<DatabaseAppSettings>();
String connectionString = dbConfig?.ConnectionString ?? "";
NpgsqlDataSourceBuilder npgDataSourceBuilder = new NpgsqlDataSourceBuilder(connectionString);
npgDataSourceBuilder.MapEnum<ClothingItem>();
npgDataSourceBuilder.MapEnum<ClothingType>();
npgDataSource = npgDataSourceBuilder.Build();
// may want to put into sql table and read into dict statically making the coupling looser or something idek
ClothingItemWeightMap = new Dictionary<ClothingItem, int>
{
{ClothingItem.TShirt, 40},
{ClothingItem.LongSleeve, 45},
{ClothingItem.Pants, 45},
{ClothingItem.Socks, 5},
{ClothingItem.Hat, 5},
{ClothingItem.Underwear, 5},
{ClothingItem.Watch, 2},
{ClothingItem.Gloves, 5},
{ClothingItem.Sweater, 45},
{ClothingItem.Jacket, 45},
{ClothingItem.Shorts, 25},
};
ClothingItemDefaultPercentageMap = new Dictionary<ClothingItem, int>
{
{ClothingItem.TShirt, 20},
{ClothingItem.LongSleeve, 20},
{ClothingItem.Pants, 20},
{ClothingItem.Socks, 20},
{ClothingItem.Hat, 20},
{ClothingItem.Underwear, 20},
{ClothingItem.Watch, 20},
{ClothingItem.Gloves, 20},
{ClothingItem.Sweater, 20},
{ClothingItem.Jacket, 20},
{ClothingItem.Shorts, 20},
};
}
public static async Task Main(string[] args)
{
await using NpgsqlCommand npgCommand = npgDataSource.CreateCommand("SELECT foo FROM test;");
await using NpgsqlDataReader npgReader = await npgCommand.ExecuteReaderAsync();
while (await npgReader.ReadAsync())
{
Console.WriteLine(npgReader.GetInt32(0));
}
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Services
.AddDiscordGateway(options =>
{
options.Intents = GatewayIntents.Guilds | GatewayIntents.GuildMessages;
})
.AddApplicationCommands();
IHost host = builder.Build();
host.AddModules(typeof(Program).Assembly);
host.UseGatewayEventHandlers();
await host.RunAsync();
}
}