serenity-rs / poise

Discord bot command framework for serenity, with advanced features like edit tracking and flexible argument parsing
MIT License
678 stars 117 forks source link

Crash in serenity::Client = client_builder.event_handler(event_handler) #150

Closed eklipse2k8 closed 1 year ago

eklipse2k8 commented 1 year ago

With a basic example, I am getting a crash, so it never tries to connect.

poise::Framework::builder()
        .token(DISCORD_BOT_CLIENT_TOKEN.to_string())
        .intents(GatewayIntents::non_privileged())
        .options(poise::FrameworkOptions {
          commands: vec![age()],
          ..Default::default()
        })
        .setup(|ctx, _ready, framework| {
          Box::pin(async move {
            poise::builtins::register_globally(ctx, &framework.options().commands).await?;
            Ok(DiscordAppState {
              db: db.clone(),
              cache: cache.clone(),
              notif: notif.clone(),
            })
          })
        })
        .run_autosharded()
        .await
        .unwrap()
  14:        0x106c6b990 - core::panicking::panic_fmt::hac8e674b2bd0119d
                               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/panicking.rs:64:14
  15:        0x106c1dee0 - core::panicking::panic_display::h8ab30fd93b89ab9a
                               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/panicking.rs:147:5
  16:        0x106c1dea4 - core::panicking::panic_str::hac9c193b56e0b238
                               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/panicking.rs:131:5
  17:        0x106c6b95c - core::option::expect_failed::h6156e0e8c434e3fc
                               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/option.rs:1924:5
  18:        0x1051a6020 - core::option::Option<T>::expect::habda05ff991959df
                               at /rustc/8460ca823e8367a30dda430efda790588b8c84d3/library/core/src/option.rs:786:21
  19:        0x10535dffc - <serenity::client::ClientBuilder as core::future::future::Future>::poll::hf823716d94c569fd
                               at /Users/mjarjoura/.cargo/registry/src/github.com-1ecc6299db9ec823/serenity-0.11.5/src/client/mod.rs:360:29
  20:        0x104265544 - poise::framework::Framework<U,E>::new::{{closure}}::hed4d0d7a3f319ee6
                               at /Users/mjarjoura/.cargo/registry/src/github.com-1ecc6299db9ec823/poise-0.5.2/src/framework/mod.rs:111:83
  21:        0x1042f9fb0 - poise::framework::builder::FrameworkBuilder<U,E>::build::{{closure}}::hfb6e0eb60e729ffb
                               at /Users/mjarjoura/.cargo/registry/src/github.com-1ecc6299db9ec823/poise-0.5.2/src/framework/builder.rs:225:62
  22:        0x1042f93c0 - poise::framework::builder::FrameworkBuilder<U,E>::run_autosharded::{{closure}}::h1121fcc39a9f4cbe
                               at /Users/mjarjoura/.cargo/registry/src/github.com-1ecc6299db9ec823/poise-0.5.2/src/framework/builder.rs:246:21
kangalio commented 1 year ago

Please post the entire panic, including the panic message

kangalio commented 1 year ago

This is most likely a case of the "framework" feature still being enabled (judging from the line numbers from the backtrace excerpt). I specifically asked for the full panic, because the panic message contains a comprehensive explanation what the problem is and how to fix it. Closing unless some other problem crops up