jontze / cadency-rs

The cadency-rs project is a Discord bot written in Rust, capable of playing songs and playlists from YouTube. This bot is designed to enhance the functionality of Discord servers by providing music playback features directly within the server environment.
MIT License
27 stars 8 forks source link

Failed to submit response: Unknown interaction #117

Open Manw107 opened 1 year ago

Manw107 commented 1 year ago

When the user tries to use the /play command the bot answers with ':x: Couldn't add audio source to the queue!'.

The console response in case it's useful: [2023-07-06T22:10:39Z INFO cadency_core::handler::command] ⚡ Execute 'play' command [2023-07-06T22:10:39Z ERROR cadency_core::response] Failed to submit response: Unknown interaction thread 'tokio-runtime-worker' panicked at 'Unable to submit deferred info: Response', cadency_core/src/handler/command.rs:49:26 stack backtrace: 0: 0xaaaea6bcce20 - ::fmt::h7e7f1aaafc0cf2d2 1: 0xaaaea6beff4c - core::fmt::write::h0b028505b82bc0c1 2: 0xaaaea6bc6c84 - std::io::Write::write_fmt::h956aa06f020dbeed 3: 0xaaaea6bccc2c - std::sys_common::backtrace::print::h1432c0d35b51f06d 4: 0xaaaea6bce6e8 - std::panicking::default_hook::{{closure}}::he3709b970919b674 5: 0xaaaea6bce42c - std::panicking::default_hook::h06f450223d1a38ba 6: 0xaaaea6bced70 - std::panicking::rust_panic_with_hook::h4c5a2c369298e1bc 7: 0xaaaea6bceb50 - std::panicking::begin_panic_handler::{{closure}}::h5a80bba510c18577 8: 0xaaaea6bcd2b0 - std::sys_common::backtrace::rust_end_short_backtrace::ha6d29e38acd9daf6 9: 0xaaaea6bce894 - rust_begin_unwind 10: 0xaaaea55c8b4c - core::panicking::panic_fmt::hb2f2a43d40c93c4f 11: 0xaaaea55c8d34 - core::result::unwrap_failed::h3dfded8c0af49953 12: 0xaaaea589c61c - core::result::Result<T,E>::expect::h8fcddbc33f9ca5df at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/result.rs:1070:23 13: 0xaaaea589f974 - ::interaction_create::{{closure}}::ha92a2286a927bcca at /home/opc/youtube-bot/cadency_core/src/handler/command.rs:44:21 14: 0xaaaea58a6784 - <core::future::from_generator::GenFuture as core::future::future::Future>::poll::h8403737604239269 at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/future/mod.rs:91:19 15: 0xaaaea5e6ca38 - <core::pin::Pin

as core::future::future::Future>::poll::h04e453e202f01728 at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/future/future.rs:124:9 16: 0xaaaea5b78d88 - serenity::client::dispatch::handle_event::{{closure}}::{{closure}}::{{closure}}::h8956950b4af0da37 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/serenity-0.11.6/src/client/dispatch.rs:744:77 17: 0xaaaea5ff486c - <core::future::from_generator::GenFuture as core::future::future::Future>::poll::h61691f27a311ded1 at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/future/mod.rs:91:19 18: 0xaaaea5e6e0a0 - <core::pin::Pin

as core::future::future::Future>::poll::hbe84908c390bb004 at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/future/future.rs:124:9 19: 0xaaaea60ad0a4 - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h8bbd6042a3d524ce at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/core.rs:311:17 20: 0xaaaea5cc6978 - tokio::loom::std::unsafe_cell::UnsafeCell::with_mut::hec978478c5b6c80b at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/loom/std/unsafe_cell.rs:14:9 21: 0xaaaea609d298 - tokio::runtime::task::core::Core<T,S>::poll::hed6916d731838527 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/core.rs:300:13 22: 0xaaaea62e8ed8 - tokio::runtime::task::harness::poll_future::{{closure}}::h7a7119156a7d876d at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:476:19 23: 0xaaaea5fcd270 - <core::panic::unwind_safe::AssertUnwindSafe as core::ops::function::FnOnce<()>>::call_once::h3a3d6083285a14d9 at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/panic/unwind_safe.rs:271:9 24: 0xaaaea6260af0 - std::panicking::try::do_call::hb2d3fcc36837cdfe at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panicking.rs:483:40 25: 0xaaaea629d6e0 - rust_try 26: 0xaaaea620c804 - std::panicking::try::h3ed320d2e8f83a9b at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panicking.rs:447:19 27: 0xaaaea5cee6d8 - std::panic::catch_unwind::h9da8da10d7c15fb6 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panic.rs:137:14 28: 0xaaaea62b8044 - tokio::runtime::task::harness::poll_future::h1d1f31f860435e4e at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:464:18 29: 0xaaaea62f856c - tokio::runtime::task::harness::Harness<T,S>::poll_inner::h15a432daed38c380 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:198:27 30: 0xaaaea6344a1c - tokio::runtime::task::harness::Harness<T,S>::poll::h469d70680bc77016 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:152:15 31: 0xaaaea618c810 - tokio::runtime::task::raw::poll::h196fcf7cae6c40de at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/raw.rs:276:5 32: 0xaaaea68f1f28 - tokio::runtime::task::raw::RawTask::poll::hcb6dda8ccca8b6ed at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/raw.rs:200:18 33: 0xaaaea68feeb0 - tokio::runtime::task::LocalNotified::run::hc92ff9a9978e4eee at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/mod.rs:400:9 34: 0xaaaea690e364 - tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}::h3cdc073515aa1b7e at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:639:17 35: 0xaaaea690de10 - tokio::runtime::coop::with_budget::h1712d68f5a84ba45 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/coop.rs:107:5 36: 0xaaaea690de10 - tokio::runtime::coop::budget::h147f87b3486494e0 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/coop.rs:73:5 37: 0xaaaea690de10 - tokio::runtime::scheduler::multi_thread::worker::Context::run_task::h915e53b98737c9f4 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:575:9 38: 0xaaaea690d6d8 - tokio::runtime::scheduler::multi_thread::worker::Context::run::hea8a85b27c57e63c at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:526:24 39: 0xaaaea690d47c - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}::h2917b6e1fe55a84a at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:491:21 40: 0xaaaea68d464c - tokio::runtime::context::scoped::Scoped::set::hc7c4148c32ab6e3a at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/context/scoped.rs:40:9 41: 0xaaaea693e1c4 - tokio::runtime::context::set_scheduler::{{closure}}::h673ad26400c9e7a1 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/context.rs:176:26 42: 0xaaaea68a6d8c - std::thread::local::LocalKey::try_with::hf9fa644e862300b0 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/thread/local.rs:446:16 43: 0xaaaea68a45e0 - std::thread::local::LocalKey::with::h327c65c7f256fa00 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/thread/local.rs:422:9 44: 0xaaaea693e148 - tokio::runtime::context::set_scheduler::h7849ce7b8bc2797f at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/context.rs:176:9 45: 0xaaaea690d3a0 - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::h15ef0966f452b370 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:486:9 46: 0xaaaea68e9f38 - tokio::runtime::context::runtime::enter_runtime::ha63a27489c6f3236 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/context/runtime.rs:65:16 47: 0xaaaea690d188 - tokio::runtime::scheduler::multi_thread::worker::run::hb83099a616a7073d at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:478:5 48: 0xaaaea690d03c - tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}::h86d0102c82b97a6d at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:447:45 49: 0xaaaea68c381c - <tokio::runtime::blocking::task::BlockingTask as core::future::future::Future>::poll::hb773c93889f2d7ed at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/blocking/task.rs:42:21 50: 0xaaaea68bcbcc - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h64703a4895458d97 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/core.rs:311:17 51: 0xaaaea6929c44 - tokio::loom::std::unsafe_cell::UnsafeCell::with_mut::he5e455e020531998 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/loom/std/unsafe_cell.rs:14:9 52: 0xaaaea68bc578 - tokio::runtime::task::core::Core<T,S>::poll::h9f549b6c139f45b2 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/core.rs:300:13 53: 0xaaaea694ae78 - tokio::runtime::task::harness::poll_future::{{closure}}::hfd32d8e31bf0d498 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:476:19 54: 0xaaaea68f2f64 - <core::panic::unwind_safe::AssertUnwindSafe as core::ops::function::FnOnce<()>>::call_once::h32d35ac696ee8541 at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/panic/unwind_safe.rs:271:9 55: 0xaaaea69576c4 - std::panicking::try::do_call::he405d8c617260e90 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panicking.rs:483:40 56: 0xaaaea69593c0 - rust_try 57: 0xaaaea6954bac - std::panicking::try::h6dfda46ace8764d4 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panicking.rs:447:19 58: 0xaaaea6938e14 - std::panic::catch_unwind::hadcf7ab49123674f at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panic.rs:137:14 59: 0xaaaea694a100 - tokio::runtime::task::harness::poll_future::h69f3e896d9a1433d at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:464:18 60: 0xaaaea6944ab8 - tokio::runtime::task::harness::Harness<T,S>::poll_inner::h30f4266ec631f904 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:198:27 61: 0xaaaea6944658 - tokio::runtime::task::harness::Harness<T,S>::poll::h56186a6269250c1a at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/harness.rs:152:15 62: 0xaaaea68f222c - tokio::runtime::task::raw::poll::h174218a0269b38fe at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/raw.rs:276:5 63: 0xaaaea68f1f28 - tokio::runtime::task::raw::RawTask::poll::hcb6dda8ccca8b6ed at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/raw.rs:200:18 64: 0xaaaea68fef7c - tokio::runtime::task::UnownedTask::run::h4816a5d6f60b84e2 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/task/mod.rs:437:9 65: 0xaaaea68bf704 - tokio::runtime::blocking::pool::Task::run::hec60ec3fbc956772 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/blocking/pool.rs:159:9 66: 0xaaaea68c336c - tokio::runtime::blocking::pool::Inner::run::h86b46f48f33b88f8 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/blocking/pool.rs:513:17 67: 0xaaaea68c2a78 - tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}::h04db02853d0e9952 at /home/opc/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.29.1/src/runtime/blocking/pool.rs:471:13 68: 0xaaaea68f388c - std::sys_common::backtrace::rust_begin_short_backtrace::h7150c4c6a2cf812f at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/sys_common/backtrace.rs:121:18 69: 0xaaaea68cef44 - std::thread::Builder::spawnunchecked::{{closure}}::{{closure}}::ha37c1ee073b9ca9e at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/thread/mod.rs:551:17 70: 0xaaaea68f35e8 - <core::panic::unwind_safe::AssertUnwindSafe as core::ops::function::FnOnce<()>>::call_once::hf51ddb39caefac05 at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/panic/unwind_safe.rs:271:9 71: 0xaaaea6956d68 - std::panicking::try::do_call::h7d726ca0ae2fe496 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panicking.rs:483:40 72: 0xaaaea69593c0 - __rust_try 73: 0xaaaea6954694 - std::panicking::try::h4ca81c2982f8bc65 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panicking.rs:447:19 74: 0xaaaea6938ec4 - std::panic::catch_unwind::hd7be967759e3f5a1 at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/panic.rs:137:14 75: 0xaaaea68cedac - std::thread::Builder::spawnunchecked::{{closure}}::h7983506e3141e1fd at /builddir/build/BUILD/rustc-1.66.1-src/library/std/src/thread/mod.rs:550:30 76: 0xaaaea691adb8 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h91d3452caa4660ea at /builddir/build/BUILD/rustc-1.66.1-src/library/core/src/ops/function.rs:251:5 77: 0xaaaea6bd3168 - std::sys::unix::thread::Thread::new::thread_start::h4f9b99c50c6adb95 78: 0xfffe4a1d7928 - start_thread 79: 0xfffe49f73e1c - thread_start 80: 0x0 -

jontze commented 1 year ago

Thanks for your feedback @Manw107

I looked into this and the error thrown in the stack trace Failed to submit response: Unknown interaction bubbles up from the serenity framework. Serenity throws this error if the submitted command is not known by discord (=Unknown interaction).

This is a strong indicator that the commands (=interactions) weren't finished with the registration to the discord api. This can happen due to the following reasons:

  1. The bot wasn't ready yet and the command was executed before all commands were submitted to the discord api. You can check this by looking at your logs. You should not submit any commands to the bot before the ✅ Application commands submitted log appears. As you see in the logs below, this can take a few seconds.
    [2023-07-07T12:49:33Z INFO  cadency_core::handler::command] 🚀 Start Cadency Discord Bot
    [2023-07-07T12:49:33Z INFO  cadency_core::handler::command] ⏳ Started to submit commands, please wait...
    [2023-07-07T12:50:14Z INFO  cadency_core::handler::command] ✅ Application commands submitted
    [2023-07-07T12:51:28Z INFO  cadency_core::handler::command] ⚡ Execute 'play' command
    [2023-07-07T12:51:32Z INFO  cadency_core::handler::command] ✅ Command 'play' was successful
  2. The bot was started for the first time and therefore the commands were submitted for the first time to discord. As these commands are global, it can take up to 1 hour until the commands are available, according to the serentiy documentation: https://docs.rs/serenity/latest/serenity/http/client/struct.Http.html#method.create_global_application_command

So the issue might be resolved by waiting a little bit. From my experience it mostly doesn't take a full hour until the commands are working.

sintaxx commented 1 year ago

What is the best solution for this issue? I tried restarting the bot and waiting 12 hours and still same message about audio source cannot be added

jontze commented 1 year ago

@sintaxx Could you please provide me with the logs?

The message ❌ Couldn't add audio source to the queue! can have multiple root causes and I want to verify that this is actually the same as reported above.

Do you use the latest docker image?

Manw107 commented 1 year ago

Hi, sorry if it took me a lot to answer.

  1. The bot was started for the first time and therefore the commands were submitted for the first time to discord. As these commands are global, it can take up to 1 hour until the commands are available, according to the serentiy documentation: https://docs.rs/serenity/latest/serenity/http/client/struct.Http.html#method.create_global_application_command

This is probably the reason why the /play command doesn't work because I always wait for ✅ Application commands submitted Btw could the OS or the architecure of the host be the source of the problem?

jontze commented 1 year ago

@Manw107 I just tried it out with a brand new discord bot. I'm unable to reproduce this. :|

Do you use the docker image and are you on the latest version? If not, this might be the issue, as older docker builds use very likely an outdated yt-dlp version and this has caused problems in the past. Thats why I publish a new cadency version with every yt-dlp update...

Btw could the OS or the architecure of the host be the source of the problem? Right now, I'm not aware of any platform specific issues. As long as you use the docker image you should be fine. And the image supports arm64 and amd64.