discord-net/Discord.Net

[Bug]: client.Ready not firing

Wqffles-com opened this issue · 2 comments

Check The Docs

  • I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

When I try to start up my bot, it connects and logs in but the Ready event is never fired.

Version

3.13.0

Working Version

No response

Logs

info: BlahajBot.Bot[0]
      Discord.Net v3.13.0 (API v10)
info: BlahajBot.Bot[0]
      Logged in!
info: BlahajBot.Bot[0]
      Connecting
info: BlahajBot.Bot[0]
      Connected
info: BlahajBot.Bot[0]
      Connected!

Sample

var client = _serviceProvider.GetRequiredService<DiscordSocketClient>();
 client.Ready += () => 
        {
            Console.WriteLine("Bot is connected!");
            return Task.CompletedTask;
        };

Service Provider:

public static IServiceProvider CreateServices()
    {
        var config = new DiscordSocketConfig
        {
            AlwaysDownloadUsers = true,
            AlwaysDownloadDefaultStickers = true,
            GatewayIntents = GatewayIntents.None
        };

        var servConfig = new InteractionServiceConfig
        {
            DefaultRunMode = RunMode.Async,
        };

        var collection = new ServiceCollection()
            .AddSingleton(config)
            .AddSingleton<DiscordSocketClient>()
            .AddSingleton(servConfig)
            .AddSingleton<InteractionService>();

        return collection.BuildServiceProvider();
    }

Logging:

private Task Log(LogMessage msg)
    {
        switch (msg.Severity)
        {
            case LogSeverity.Critical: Logger.LogCritical(msg.Message);
                break;
            case LogSeverity.Error: Logger.LogError(msg.Message);
                break;
            case LogSeverity.Warning: Logger.LogWarning(msg.Message);
                break;
            case LogSeverity.Info: Logger.LogInformation(msg.Message);
                break;
            case LogSeverity.Verbose: Logger.LogDebug(msg.Message);
                break;
            case LogSeverity.Debug: Logger.LogTrace(msg.Message);
                break;
            default: Logger.LogInformation(msg.Message);
                break;
        }

        return Task.CompletedTask;
    }

Packages

Microsoft.Extensions.Logging v8.0.0
Microsoft.Extensions.Logging.Console v8.0.0

Environment

  • OS: Windows 11, 10.0.22621 Build 22621
  • Arch: x64
  • .NET: 7.0.311
  • SDK: 7.0.305, 7.0.306, 7.0.311

You have AlwaysDownloadUsers set to true in your DiscordSocketConfig. One requires GuildMembers intent to be enabled.

  • DNet should log a warning, but rn it just silently fails. This is a known issue and a PR with the fix has been merged already; it will come in the next patch.

@Misha-133
That was the problem, thanks!