#How to do dep injection with the new Commands module
1 messages · Page 1 of 1 (latest)
It works still the same way, you provide the DiscordClient with your services and it gets used for the extensions
It should
Strange
It doesn't seem to
Or I am doing it wrong
var services = new ServiceCollection()
.AddSingleton<VoiceContext>();
DiscordClientBuilder builder =
DiscordClientBuilder.CreateDefault(Environment.GetEnvironmentVariable("DISCORD_TOKEN")!, intents, services);
This is how I am doing it now, as I notice its on the builder now.
and here is how i use it https://pastes.dev/9LOxxV6VAt
VoiceContext is my db context through efcore
Commands are Singletons by default so you can't inject a scoped service like Ef core contexts