Microsoft.Extensions.Logging.Console
I try to build a Discord bot. I follow the instructions here:
https://dsharpplus.github.io/DSharpPlus/articles/migration/slashcommands_to_commands.html
but I doesn't work (I added
Microsoft.Extensions.Logging.Console
).3 Replies
Define "doesn't work"?
Show some code where you're using this logger
For bots, I strongly recommend using the Worker Service template.
dotnet new worker
on the cli
When setting up the command config, just give it the same service provider you use for everything else.
In the worker service, have IServiceProvider injected, and put the bot startup code (ConnectAsync and all that) in the ExecuteAsync
Or actually I guess you could ditch the worker, and start the bot in Program.csIt still gives
CS1061
for AddConsole()
after adding the NuGet package (Microsoft.Extensions.Logging.Console
).
I get use it from inside MyBot.Bot.Bot.RunAsync()
I call the RunAsync()
(command to start the bot) inslde Program.Main()
Thanks for your suggestion.