I am using a discord bot as a logger to for an ASP.NET api. Its running as a background process
i just noticed that my logger hasn't logged anything in a month. so i dug into the process and noticed something weird. here's my simplified logging code:
if (_client.ConnectionState == ConnectionState.Connected) {
...
}
else {
Console.WriteLine($"Attempted to send a log to discord but bot is {_client.ConnectionState}:" +
$"\n\t{log.Message}");
}
the point of this part of the code is to send logs to discord if your connected, but otherwise to dump the message on the console.
here's the console when i start the API:
Attempted to send a log to discord but bot is Disconnected:
Discord.Net v3.15.3 (API v10)
Attempted to send a log to discord but bot is Connecting:
Connecting
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5154
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\<username>\Desktop\Ward Management\MyWardDataLayer\MyWardDataLayer
Attempted to send a log to discord but bot is Connecting:
Connected
the last line is the head-scratcher. why does the system think its connected?!