-
Notifications
You must be signed in to change notification settings - Fork 0
/
Services.fs
36 lines (28 loc) · 876 Bytes
/
Services.fs
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
module Services
open Discord
open Discord.Commands
open Discord.WebSocket
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Logging
open System.IO
open System.Threading.Tasks
open System
open System.Text.Json
type Config = { Token: string }
let config =
let options =
JsonSerializerOptions(PropertyNamingPolicy = JsonNamingPolicy.CamelCase)
let json = File.ReadAllText("config.json")
JsonSerializer.Deserialize<Config>(json, options)
let discord =
let log (msg: LogMessage) =
printfn "%s" <| msg.ToString()
Task.CompletedTask
let client = new DiscordSocketClient()
Func<_, _>(log) |> client.add_Log
client
let commands = new CommandService()
let provider =
ServiceCollection()
.AddLogging(fun loggingBuilder -> loggingBuilder.AddConsole() |> ignore)
.BuildServiceProvider()