Hi All,
Hoping someone can help me out here
Im using dependancy injection within my application
In my DiscordModule.cs I have
{
GatewayIntents = global::Discord.GatewayIntents.AllUnprivileged,
AlwaysDownloadUsers = true,
}));
services.AddSingleton(x => new InteractionService(x.GetRequiredService<DiscordSocketClient>()));
services.AddSingleton<CommandHandler>();```
In my `ReadyAsync()` I have
```Console.WriteLine($"Connected as -> [{_client.CurrentUser}] :)");
Console.WriteLine("Discord: " + _client.Status.ToString());
Console.WriteLine("Guild Count: " + _client.Guilds.Count);```
And in an API Endpoint controller, I have
```public TestController(DiscordSocketClient discord, IServiceProvider provider)
{
Console.WriteLine("In TestController Constructor");
_discord = discord;
_provider = provider;
}``` ```public string Get([FromRoute] TestModel model)
{
Console.WriteLine("Discord: " + _discord.Status.ToString());
Console.WriteLine("Guild Count: " + _discord.Guilds.Count);
var guilds = _discord.Guilds;
foreach (var guild in guilds)
{
Console.WriteLine("Guild: " + guild.Id);
}
return "TEST";
}```
When I start the application, I see that `ReadyAsync` gets called as I get
```In debug mode, adding commands to 6057XXXXXXXXXXXX0...
Connected as -> [?TestUser?#1234] :)
Discord: Online
Guild Count: 1
Guild: 6057XXXXXXXXXXXX0
16:16:53 Gateway Ready```
But if I call the API endpoint I get
```Discord: Online
Guild Count: 0``` and `TEST` gets returned from the controller
From the API Controller, if I try `var test = _discord.GetGuild(6057XXXXXXXXXXXX0);` test is null
I really cant see what Im missing here and why the guild list is empty when I try from the API Controller
Thanks in advanced