pub struct BotApi { /* private fields */ }
Expand description
Bot API client for the QQ Guild Bot API.
Implementations§
Source§impl BotApi
impl BotApi
Sourcepub fn new(http: HttpClient) -> Self
pub fn new(http: HttpClient) -> Self
Sourcepub async fn get_bot_info(&self, token: &Token) -> Result<BotInfo>
pub async fn get_bot_info(&self, token: &Token) -> Result<BotInfo>
Sourcepub async fn get_gateway(&self, token: &Token) -> Result<GatewayResponse>
pub async fn get_gateway(&self, token: &Token) -> Result<GatewayResponse>
Sourcepub async fn get_guilds(
&self,
token: &Token,
guild_id: Option<&str>,
limit: Option<u32>,
desc: Option<bool>,
) -> Result<Vec<Guild>>
pub async fn get_guilds( &self, token: &Token, guild_id: Option<&str>, limit: Option<u32>, desc: Option<bool>, ) -> Result<Vec<Guild>>
Sourcepub async fn get_guild_roles(
&self,
token: &Token,
guild_id: &str,
) -> Result<GuildRoles>
pub async fn get_guild_roles( &self, token: &Token, guild_id: &str, ) -> Result<GuildRoles>
Sourcepub async fn create_guild_role(
&self,
token: &Token,
guild_id: &str,
name: Option<&str>,
color: Option<u32>,
hoist: Option<bool>,
) -> Result<GuildRole>
pub async fn create_guild_role( &self, token: &Token, guild_id: &str, name: Option<&str>, color: Option<u32>, hoist: Option<bool>, ) -> Result<GuildRole>
Sourcepub async fn update_guild_role(
&self,
token: &Token,
guild_id: &str,
role_id: &str,
name: Option<&str>,
color: Option<u32>,
hoist: Option<bool>,
) -> Result<GuildRole>
pub async fn update_guild_role( &self, token: &Token, guild_id: &str, role_id: &str, name: Option<&str>, color: Option<u32>, hoist: Option<bool>, ) -> Result<GuildRole>
Sourcepub async fn delete_guild_role(
&self,
token: &Token,
guild_id: &str,
role_id: &str,
) -> Result<()>
pub async fn delete_guild_role( &self, token: &Token, guild_id: &str, role_id: &str, ) -> Result<()>
Sourcepub async fn create_guild_role_member(
&self,
token: &Token,
guild_id: &str,
role_id: &str,
user_id: &str,
channel_id: Option<&str>,
) -> Result<()>
pub async fn create_guild_role_member( &self, token: &Token, guild_id: &str, role_id: &str, user_id: &str, channel_id: Option<&str>, ) -> Result<()>
Sourcepub async fn delete_guild_role_member(
&self,
token: &Token,
guild_id: &str,
role_id: &str,
user_id: &str,
channel_id: Option<&str>,
) -> Result<()>
pub async fn delete_guild_role_member( &self, token: &Token, guild_id: &str, role_id: &str, user_id: &str, channel_id: Option<&str>, ) -> Result<()>
Sourcepub async fn get_guild_member(
&self,
token: &Token,
guild_id: &str,
user_id: &str,
) -> Result<Member>
pub async fn get_guild_member( &self, token: &Token, guild_id: &str, user_id: &str, ) -> Result<Member>
Sourcepub async fn get_guild_members(
&self,
token: &Token,
guild_id: &str,
after: Option<&str>,
limit: Option<u32>,
) -> Result<Vec<Member>>
pub async fn get_guild_members( &self, token: &Token, guild_id: &str, after: Option<&str>, limit: Option<u32>, ) -> Result<Vec<Member>>
Sourcepub async fn delete_member(
&self,
token: &Token,
guild_id: &str,
user_id: &str,
add_blacklist: Option<bool>,
delete_history_msg_days: Option<i32>,
) -> Result<()>
pub async fn delete_member( &self, token: &Token, guild_id: &str, user_id: &str, add_blacklist: Option<bool>, delete_history_msg_days: Option<i32>, ) -> Result<()>
Sourcepub async fn create_channel(
&self,
token: &Token,
guild_id: &str,
name: &str,
channel_type: ChannelType,
sub_type: ChannelSubType,
position: Option<u32>,
parent_id: Option<&str>,
private_type: Option<u32>,
private_user_ids: Option<Vec<String>>,
speak_permission: Option<u32>,
application_id: Option<&str>,
) -> Result<Channel>
pub async fn create_channel( &self, token: &Token, guild_id: &str, name: &str, channel_type: ChannelType, sub_type: ChannelSubType, position: Option<u32>, parent_id: Option<&str>, private_type: Option<u32>, private_user_ids: Option<Vec<String>>, speak_permission: Option<u32>, application_id: Option<&str>, ) -> Result<Channel>
Creates a new channel.
§Arguments
token
- Authentication tokenguild_id
- The guild IDname
- Channel namechannel_type
- Channel typesub_type
- Channel sub-typeposition
- Optional positionparent_id
- Optional parent category IDprivate_type
- Optional private typeprivate_user_ids
- Optional private user IDsspeak_permission
- Optional speak permissionapplication_id
- Optional application ID
§Returns
The created channel.
Sourcepub async fn update_channel(
&self,
token: &Token,
channel_id: &str,
name: Option<&str>,
position: Option<u32>,
parent_id: Option<&str>,
private_type: Option<u32>,
speak_permission: Option<u32>,
) -> Result<Channel>
pub async fn update_channel( &self, token: &Token, channel_id: &str, name: Option<&str>, position: Option<u32>, parent_id: Option<&str>, private_type: Option<u32>, speak_permission: Option<u32>, ) -> Result<Channel>
Sourcepub async fn get_message(
&self,
token: &Token,
channel_id: &str,
message_id: &str,
) -> Result<Message>
pub async fn get_message( &self, token: &Token, channel_id: &str, message_id: &str, ) -> Result<Message>
Sourcepub async fn post_message_with_params(
&self,
token: &Token,
channel_id: &str,
params: MessageParams,
) -> Result<MessageResponse>
pub async fn post_message_with_params( &self, token: &Token, channel_id: &str, params: MessageParams, ) -> Result<MessageResponse>
Sends a message to a channel using MessageParams.
This is the new, recommended way to send channel messages. It uses a parameter struct instead of many optional arguments, making the code cleaner and more maintainable.
§Arguments
token
- Authentication tokenchannel_id
- The channel IDparams
- Message parameters (seeMessageParams
)
§Returns
The sent message response.
§Examples
// Simple text message
let params = MessageParams::new_text("Hello world!");
api.post_message_with_params(token, "channel_id", params).await?;
// Message with reply
let params = MessageParams::new_text("Reply!").with_reply("message_id");
api.post_message_with_params(token, "channel_id", params).await?;
Sourcepub async fn post_message(
&self,
token: &Token,
channel_id: &str,
content: Option<&str>,
embed: Option<&Embed>,
ark: Option<&Ark>,
message_reference: Option<&Reference>,
image: Option<&str>,
file_image: Option<&[u8]>,
msg_id: Option<&str>,
event_id: Option<&str>,
markdown: Option<&MarkdownPayload>,
keyboard: Option<&Keyboard>,
) -> Result<MessageResponse>
👎Deprecated since 0.1.0: Use post_message_with_params instead
pub async fn post_message( &self, token: &Token, channel_id: &str, content: Option<&str>, embed: Option<&Embed>, ark: Option<&Ark>, message_reference: Option<&Reference>, image: Option<&str>, file_image: Option<&[u8]>, msg_id: Option<&str>, event_id: Option<&str>, markdown: Option<&MarkdownPayload>, keyboard: Option<&Keyboard>, ) -> Result<MessageResponse>
Sends a message to a channel (legacy API for backward compatibility).
§Arguments
token
- Authentication tokenchannel_id
- The channel IDcontent
- Message contentembed
- Optional embedark
- Optional ark templatemessage_reference
- Optional message referenceimage
- Optional image URLfile_image
- Optional file image datamsg_id
- Optional message ID to reply toevent_id
- Optional event IDmarkdown
- Optional markdownkeyboard
- Optional keyboard
§Returns
The sent message response.
Sourcepub async fn post_group_message_with_params(
&self,
token: &Token,
group_openid: &str,
params: GroupMessageParams,
) -> Result<MessageResponse>
pub async fn post_group_message_with_params( &self, token: &Token, group_openid: &str, params: GroupMessageParams, ) -> Result<MessageResponse>
Sends a group message using GroupMessageParams.
This is the new, recommended way to send group messages. It uses a parameter struct instead of many optional arguments, making the code cleaner and more maintainable.
§Arguments
token
- Authentication tokengroup_openid
- The group OpenIDparams
- Group message parameters (seeGroupMessageParams
)
§Returns
The sent group message response.
§Examples
let params = GroupMessageParams::new_text("Hello group!");
api.post_group_message_with_params(token, "group_openid", params).await?;
Sourcepub async fn post_group_message(
&self,
token: &Token,
group_openid: &str,
msg_type: Option<u32>,
content: Option<&str>,
embed: Option<&Embed>,
ark: Option<&Ark>,
message_reference: Option<&Reference>,
media: Option<&Media>,
msg_id: Option<&str>,
msg_seq: Option<u32>,
event_id: Option<&str>,
markdown: Option<&MarkdownPayload>,
keyboard: Option<&KeyboardPayload>,
) -> Result<MessageResponse>
👎Deprecated since 0.1.0: Use post_group_message_with_params instead
pub async fn post_group_message( &self, token: &Token, group_openid: &str, msg_type: Option<u32>, content: Option<&str>, embed: Option<&Embed>, ark: Option<&Ark>, message_reference: Option<&Reference>, media: Option<&Media>, msg_id: Option<&str>, msg_seq: Option<u32>, event_id: Option<&str>, markdown: Option<&MarkdownPayload>, keyboard: Option<&KeyboardPayload>, ) -> Result<MessageResponse>
Sends a group message (legacy API for backward compatibility).
§Arguments
token
- Authentication tokengroup_openid
- The group OpenIDmsg_type
- Message type (0=text, 1=rich text, 2=markdown, 3=ark, 4=embed, 7=media)content
- Message contentembed
- Optional embedark
- Optional ark templatemessage_reference
- Optional message referencemedia
- Optional mediamsg_id
- Optional message ID to reply tomsg_seq
- Optional message sequence numberevent_id
- Optional event IDmarkdown
- Optional markdownkeyboard
- Optional keyboard
§Returns
The sent group message response.
Sourcepub async fn post_c2c_message_with_params(
&self,
token: &Token,
openid: &str,
params: C2CMessageParams,
) -> Result<MessageResponse>
pub async fn post_c2c_message_with_params( &self, token: &Token, openid: &str, params: C2CMessageParams, ) -> Result<MessageResponse>
Sends a C2C (client-to-client) message using C2CMessageParams.
This is the new, recommended way to send C2C messages. It uses a parameter struct instead of many optional arguments, making the code cleaner and more maintainable.
§Arguments
token
- Authentication tokenopenid
- The user’s OpenIDparams
- C2C message parameters (seeC2CMessageParams
)
§Returns
The sent C2C message response.
§Examples
let params = C2CMessageParams::new_text("Hello user!");
api.post_c2c_message_with_params(token, "user_openid", params).await?;
Sourcepub async fn post_c2c_message(
&self,
token: &Token,
openid: &str,
msg_type: Option<u32>,
content: Option<&str>,
embed: Option<&Embed>,
ark: Option<&Ark>,
message_reference: Option<&Reference>,
media: Option<&Media>,
msg_id: Option<&str>,
msg_seq: Option<u32>,
event_id: Option<&str>,
markdown: Option<&MarkdownPayload>,
keyboard: Option<&KeyboardPayload>,
) -> Result<MessageResponse>
👎Deprecated since 0.1.0: Use post_c2c_message_with_params instead
pub async fn post_c2c_message( &self, token: &Token, openid: &str, msg_type: Option<u32>, content: Option<&str>, embed: Option<&Embed>, ark: Option<&Ark>, message_reference: Option<&Reference>, media: Option<&Media>, msg_id: Option<&str>, msg_seq: Option<u32>, event_id: Option<&str>, markdown: Option<&MarkdownPayload>, keyboard: Option<&KeyboardPayload>, ) -> Result<MessageResponse>
Sends a C2C (client-to-client) message (legacy API for backward compatibility).
§Arguments
token
- Authentication tokenopenid
- The user’s OpenIDmsg_type
- Message type (0=text, 1=rich text, 2=markdown, 3=ark, 4=embed, 7=media)content
- Message contentembed
- Optional embedark
- Optional ark templatemessage_reference
- Optional message referencemedia
- Optional mediamsg_id
- Optional message ID to reply tomsg_seq
- Optional message sequence numberevent_id
- Optional event IDmarkdown
- Optional markdownkeyboard
- Optional keyboard
§Returns
The sent C2C message response.
Sourcepub async fn post_dms_with_params(
&self,
token: &Token,
guild_id: &str,
params: DirectMessageParams,
) -> Result<MessageResponse>
pub async fn post_dms_with_params( &self, token: &Token, guild_id: &str, params: DirectMessageParams, ) -> Result<MessageResponse>
Sends a direct message using DirectMessageParams.
This is the new, recommended way to send direct messages. It uses a parameter struct instead of many optional arguments, making the code cleaner and more maintainable.
§Arguments
token
- Authentication tokenguild_id
- The DM session guild IDparams
- Direct message parameters (seeDirectMessageParams
)
§Returns
The sent direct message response.
§Examples
let params = DirectMessageParams::new_text("Hello DM!");
api.post_dms_with_params(token, "guild_id", params).await?;
Sourcepub async fn post_dms(
&self,
token: &Token,
guild_id: &str,
content: Option<&str>,
embed: Option<&Embed>,
ark: Option<&Ark>,
message_reference: Option<&Reference>,
image: Option<&str>,
file_image: Option<&[u8]>,
msg_id: Option<&str>,
event_id: Option<&str>,
markdown: Option<&MarkdownPayload>,
keyboard: Option<&Keyboard>,
) -> Result<MessageResponse>
👎Deprecated since 0.1.0: Use post_dms_with_params instead
pub async fn post_dms( &self, token: &Token, guild_id: &str, content: Option<&str>, embed: Option<&Embed>, ark: Option<&Ark>, message_reference: Option<&Reference>, image: Option<&str>, file_image: Option<&[u8]>, msg_id: Option<&str>, event_id: Option<&str>, markdown: Option<&MarkdownPayload>, keyboard: Option<&Keyboard>, ) -> Result<MessageResponse>
Sends a direct message (legacy API for backward compatibility).
§Arguments
token
- Authentication tokenguild_id
- The DM session guild IDcontent
- Message contentembed
- Optional embedark
- Optional ark templatemessage_reference
- Optional message referenceimage
- Optional image URLfile_image
- Optional file image datamsg_id
- Optional message ID to reply toevent_id
- Optional event IDmarkdown
- Optional markdownkeyboard
- Optional keyboard
§Returns
The sent direct message response.
Sourcepub async fn create_dms(
&self,
token: &Token,
guild_id: &str,
user_id: &str,
) -> Result<Value>
pub async fn create_dms( &self, token: &Token, guild_id: &str, user_id: &str, ) -> Result<Value>
Sourcepub async fn recall_message(
&self,
token: &Token,
channel_id: &str,
message_id: &str,
hidetip: Option<bool>,
) -> Result<()>
pub async fn recall_message( &self, token: &Token, channel_id: &str, message_id: &str, hidetip: Option<bool>, ) -> Result<()>
Sourcepub async fn update_audio(
&self,
token: &Token,
channel_id: &str,
audio_control: &AudioAction,
) -> Result<()>
pub async fn update_audio( &self, token: &Token, channel_id: &str, audio_control: &AudioAction, ) -> Result<()>
Sourcepub async fn mute_all(
&self,
token: &Token,
guild_id: &str,
mute_end_timestamp: Option<&str>,
mute_seconds: Option<&str>,
) -> Result<()>
pub async fn mute_all( &self, token: &Token, guild_id: &str, mute_end_timestamp: Option<&str>, mute_seconds: Option<&str>, ) -> Result<()>
Sourcepub async fn mute_member(
&self,
token: &Token,
guild_id: &str,
user_id: &str,
mute_end_timestamp: Option<&str>,
mute_seconds: Option<&str>,
) -> Result<()>
pub async fn mute_member( &self, token: &Token, guild_id: &str, user_id: &str, mute_end_timestamp: Option<&str>, mute_seconds: Option<&str>, ) -> Result<()>
Sourcepub async fn get_channel_user_permissions(
&self,
token: &Token,
channel_id: &str,
user_id: &str,
) -> Result<ChannelPermissions>
pub async fn get_channel_user_permissions( &self, token: &Token, channel_id: &str, user_id: &str, ) -> Result<ChannelPermissions>
Sourcepub async fn get_channel_role_permissions(
&self,
token: &Token,
channel_id: &str,
role_id: &str,
) -> Result<ChannelPermissions>
pub async fn get_channel_role_permissions( &self, token: &Token, channel_id: &str, role_id: &str, ) -> Result<ChannelPermissions>
Sourcepub async fn put_reaction(
&self,
token: &Token,
channel_id: &str,
message_id: &str,
emoji_type: u32,
emoji_id: &str,
) -> Result<()>
pub async fn put_reaction( &self, token: &Token, channel_id: &str, message_id: &str, emoji_type: u32, emoji_id: &str, ) -> Result<()>
Sourcepub async fn delete_reaction(
&self,
token: &Token,
channel_id: &str,
message_id: &str,
emoji_type: u32,
emoji_id: &str,
) -> Result<()>
pub async fn delete_reaction( &self, token: &Token, channel_id: &str, message_id: &str, emoji_type: u32, emoji_id: &str, ) -> Result<()>
Sourcepub async fn put_pin(
&self,
token: &Token,
channel_id: &str,
message_id: &str,
) -> Result<Value>
pub async fn put_pin( &self, token: &Token, channel_id: &str, message_id: &str, ) -> Result<Value>
Sourcepub async fn delete_pin(
&self,
token: &Token,
channel_id: &str,
message_id: &str,
) -> Result<()>
pub async fn delete_pin( &self, token: &Token, channel_id: &str, message_id: &str, ) -> Result<()>
Sourcepub async fn post_group_file(
&self,
token: &Token,
group_openid: &str,
file_type: u32,
url: &str,
srv_send_msg: Option<bool>,
) -> Result<Value>
pub async fn post_group_file( &self, token: &Token, group_openid: &str, file_type: u32, url: &str, srv_send_msg: Option<bool>, ) -> Result<Value>
Sourcepub async fn post_c2c_file(
&self,
token: &Token,
openid: &str,
file_type: u32,
url: &str,
srv_send_msg: Option<bool>,
) -> Result<Value>
pub async fn post_c2c_file( &self, token: &Token, openid: &str, file_type: u32, url: &str, srv_send_msg: Option<bool>, ) -> Result<Value>
Sourcepub async fn create_announce(
&self,
token: &Token,
guild_id: &str,
channel_id: &str,
message_id: &str,
) -> Result<Announce>
pub async fn create_announce( &self, token: &Token, guild_id: &str, channel_id: &str, message_id: &str, ) -> Result<Announce>
Creates a message-type guild announcement.
§Arguments
token
- Authentication tokenguild_id
- The guild ID where the announcement will be createdchannel_id
- The channel ID containing the message to announcemessage_id
- The message ID to turn into an announcement
§Returns
The created announcement.
Sourcepub async fn create_recommend_announce(
&self,
token: &Token,
guild_id: &str,
announces_type: AnnouncesType,
recommend_channels: Vec<RecommendChannel>,
) -> Result<Announce>
pub async fn create_recommend_announce( &self, token: &Token, guild_id: &str, announces_type: AnnouncesType, recommend_channels: Vec<RecommendChannel>, ) -> Result<Announce>
Sourcepub async fn delete_announce(
&self,
token: &Token,
guild_id: &str,
message_id: &str,
) -> Result<Value>
pub async fn delete_announce( &self, token: &Token, guild_id: &str, message_id: &str, ) -> Result<Value>
Sourcepub async fn get_permissions(
&self,
token: &Token,
guild_id: &str,
) -> Result<Vec<APIPermission>>
pub async fn get_permissions( &self, token: &Token, guild_id: &str, ) -> Result<Vec<APIPermission>>
Sourcepub async fn post_permission_demand(
&self,
token: &Token,
guild_id: &str,
channel_id: &str,
api_identify: APIPermissionDemandIdentify,
desc: &str,
) -> Result<APIPermissionDemand>
pub async fn post_permission_demand( &self, token: &Token, guild_id: &str, channel_id: &str, api_identify: APIPermissionDemandIdentify, desc: &str, ) -> Result<APIPermissionDemand>
Creates an API permission demand request.
§Arguments
token
- Authentication tokenguild_id
- The guild ID where permission is requestedchannel_id
- The channel ID where the request will be sentapi_identify
- The API identifier for which permission is requesteddesc
- Description explaining why the permission is needed
§Returns
The created permission demand.
Sourcepub async fn get_reaction_users(
&self,
token: &Token,
channel_id: &str,
message_id: &str,
emoji_type: EmojiType,
emoji_id: &str,
cookie: Option<&str>,
limit: Option<u32>,
) -> Result<ReactionUsers>
pub async fn get_reaction_users( &self, token: &Token, channel_id: &str, message_id: &str, emoji_type: EmojiType, emoji_id: &str, cookie: Option<&str>, limit: Option<u32>, ) -> Result<ReactionUsers>
Gets the list of users who reacted with a specific emoji.
§Arguments
token
- Authentication tokenchannel_id
- The channel ID containing the messagemessage_id
- The message IDemoji_type
- The type of emoji (1 = system, 2 = custom)emoji_id
- The emoji IDcookie
- Optional pagination cookie from previous requestlimit
- Maximum number of users to return (1-100, default 20)
§Returns
List of users who reacted and pagination info.
Sourcepub async fn get_schedules(
&self,
token: &Token,
channel_id: &str,
since: Option<&str>,
) -> Result<Vec<Schedule>>
pub async fn get_schedules( &self, token: &Token, channel_id: &str, since: Option<&str>, ) -> Result<Vec<Schedule>>
Sourcepub async fn get_schedule(
&self,
token: &Token,
channel_id: &str,
schedule_id: &str,
) -> Result<Schedule>
pub async fn get_schedule( &self, token: &Token, channel_id: &str, schedule_id: &str, ) -> Result<Schedule>
Sourcepub async fn create_schedule(
&self,
token: &Token,
channel_id: &str,
name: &str,
start_timestamp: &str,
end_timestamp: &str,
jump_channel_id: &str,
remind_type: RemindType,
) -> Result<Schedule>
pub async fn create_schedule( &self, token: &Token, channel_id: &str, name: &str, start_timestamp: &str, end_timestamp: &str, jump_channel_id: &str, remind_type: RemindType, ) -> Result<Schedule>
Creates a new schedule in a channel.
§Arguments
token
- Authentication tokenchannel_id
- The schedule channel IDname
- Name of the schedulestart_timestamp
- Start time as Unix timestamp stringend_timestamp
- End time as Unix timestamp stringjump_channel_id
- Channel ID to jump to when event startsremind_type
- Type of reminder to set
§Returns
The created schedule.
Sourcepub async fn update_schedule(
&self,
token: &Token,
channel_id: &str,
schedule_id: &str,
name: &str,
start_timestamp: &str,
end_timestamp: &str,
jump_channel_id: &str,
remind_type: RemindType,
) -> Result<Schedule>
pub async fn update_schedule( &self, token: &Token, channel_id: &str, schedule_id: &str, name: &str, start_timestamp: &str, end_timestamp: &str, jump_channel_id: &str, remind_type: RemindType, ) -> Result<Schedule>
Updates an existing schedule.
§Arguments
token
- Authentication tokenchannel_id
- The schedule channel IDschedule_id
- The schedule ID to updatename
- New name of the schedulestart_timestamp
- New start time as Unix timestamp stringend_timestamp
- New end time as Unix timestamp stringjump_channel_id
- New channel ID to jump to when event startsremind_type
- New type of reminder to set
§Returns
The updated schedule.
Sourcepub async fn delete_schedule(
&self,
token: &Token,
channel_id: &str,
schedule_id: &str,
) -> Result<Value>
pub async fn delete_schedule( &self, token: &Token, channel_id: &str, schedule_id: &str, ) -> Result<Value>
Sourcepub fn http(&self) -> &HttpClient
pub fn http(&self) -> &HttpClient
Gets the HTTP client reference.