Skip to content

Calling Other QQ Open APIs

These examples show how to use BotApi for resources beyond plain message posting. Each one is a self-contained event handler that triggers the API call from a chat command.

ExampleAPI surface
guild/api_permission.rsBotApi::get_api_permissions, BotApi::post_permission_demand, APIPermissionDemandIdentify
guild/announce.rsBotApi::create_announce, BotApi::delete_announce, BotApi::create_recommend_announce, RecommendChannel, AnnouncesType
guild/schedule.rsBotApi::create_schedule, get_schedule, update_schedule, delete_schedule, RemindType
guild/pins_message.rsBotApi::get_pins, BotApi::put_pin, BotApi::delete_pin
guild/reaction_users.rsBotApi::get_reaction_users, EmojiType::System, paginates with the cookie field
guild/recall.rssession.recall_message (also available as BotApi::recall_message)
api/message_params.rsMessageParams, GroupMessageParams, C2CMessageParams, DirectMessageParams

Pattern

Every REST call is available directly on session because sessions dereference to BotApi; the token is stored inside BotApi. Errors come back as botrs::BotError. Handle them locally — the framework does not wrap calls in retries.

rust
// examples/guild/recall.rs — send, then immediately delete
let resp = session.reply("this will vanish").await?;
if let Some(message_id) = resp.id {
    session
        .recall_message(session.channel_id(), &message_id, /* hidetip */ true)
        .await?;
}

For paginated APIs like get_reaction_users, drive the loop yourself with the returned cookie and is_end fields, exactly as the example does.

See also

  • Guide: docs/guide/api-client.md
  • Source of truth for available methods: src/api/mod.rs and the files under src/api/
  • Example paths listed above under examples/

Released under the MIT License.