getChatAdministrators returns WrapperGetChatAdministrators
bugworm opened this issue · 2 comments
I'm a bit confused. Telegram documentation says: On success, returns an Array of ChatMember objects
, function.rs has #[answer = "Vector<objects::ChatMember>"]
, but it returns me telebot::functions::WrapperGetChatAdministrators
. I can't unwrap()
it, I can't use for
, and I don't sure what I can do with it.
error[E0308]: mismatched types
--> src/main.rs:108:61
|
108 | let admins: Vec<telebot::objects::ChatMember> = bot.unban_chat_administrators(msg.chat.id);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::vec::Vec`, found struct `telebot::functions::WrapperGetChatAdministrators`
|
= note: expected type `std::vec::Vec<telebot::objects::ChatMember>`
found type `telebot::functions::WrapperGetChatAdministrators`
also error about iterator
error[E0277]: the trait bound `telebot::functions::WrapperGetChatAdministrators: std::iter::Iterator` is not satisfied
--> src/main.rs:109:26
|
109 | for admin in bot.unban_chat_administrators(msg.chat.id) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `telebot::functions::WrapperGetChatAdministrators` is not an iterator; maybe try calling `.iter()` or a similar method
|
= help: the trait `std::iter::Iterator` is not implemented for `telebot::functions::WrapperGetChatAdministrators`
= note: required by `std::iter::IntoIterator::into_iter`
Hey, the structure of telebot is a bit complicated, because everything is async. If you just call the corresponding function, you get a struct which contains all configurations for the method call. You need to call send() on it and then feed the result to the event loop. You can do it in the same way as you call bot.message(..).send() in examples/reply.rs.
I hope this will help you, just ask if you have further questions.
Got it, thanks