❔ Discord Bot Service Problem
Does anyone know how to register that service properly?
20 Replies
Need to add HttpClientFactory on startup
It's a nuget i believe
I have all needed packages installed I belive
did you add HttpClientFactory to startup?
let me see
Do you want to see my project packages installed If I understood you well? Or my Program.cs file?
I'm pretty sure, the problem is that I have no IHtmlClientFactory added to my service, however i dont how to add it properly
This is how my Program.cs looks for now
However, if i try to add this line: services.AddSingleton<IHttpClientFactory>(); ,this error occurs
Which means if i understand well, that in services.AddSingleton i cant pass Interface, and i need to pass something what inherits from it
And here is where my knowledge ends xD
you should be using the
AddHttpClient()
extension methodCan you explain what do you mean?
services.AddHttpClient();
you shouldn't be manually registering itthey already have that
ohh
they arent using th ehost lol
How should I do it then?
kekw
you are making a host, but then ignoring it
what are you doing with host here
Lmao xD
it should be await host.RunAsync(); and bot should start?
follow the docs for your discord lib
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.