Message was requested but not provided in a command handler #1019
-
Hi, I'm trying to set up a bot that handles callback queries, commands and messages, and while My function dispatching this is let handler = dptree::entry()
.branch(Update::filter_callback_query().endpoint(button_handler))
.branch(
dptree::entry()
.filter_command::<Command>()
.endpoint(command_handler),
)
.branch(Update::filter_message().endpoint(message_handler));
Dispatcher::builder(bot, handler)
.dependencies(dptree::deps![SharedData(...)])
.enable_ctrlc_handler()
.build()
.dispatch()
.await; and async fn command_handler(
cfg: SharedData,
bot: Bot,
msg: Message,
cmd: Command,
) -> ResponseResult<()> {...} However when I run this and send a command, it panics with
which makes sense as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You need to let handler = dptree::entry()
.branch(Update::filter_callback_query().endpoint(button_handler))
.branch(
Update::filter_message()
.filter_command::<Command>()
.endpoint(command_handler),
)
.branch(Update::filter_message().endpoint(message_handler)); or this: let handler = dptree::entry()
.branch(Update::filter_callback_query().endpoint(button_handler))
.branch(
Update::filter_message()
.branch(filter_command::<Command, _>().endpoint(command_handler))
.endpoint(message_handler)
); |
Beta Was this translation helpful? Give feedback.
You need to
filter_message
beforefilter_command
. so, something like this:or this: