Other Types API Reference
This module covers additional data structures and utility types used throughout the QQ Guild Bot API.
Audio and Voice Types
Audio
Represents audio controls and status in voice channels.
pub struct Audio {
pub audio_control: Option<AudioControl>,
pub audio_status: Option<AudioStatus>,
}
Fields
audio_control
: Control actions for audio playbackaudio_status
: Current status of audio in the channel
AudioControl
Audio control operations.
pub struct AudioControl {
pub audio_url: Option<String>,
pub text: Option<String>,
pub status: Option<u32>,
}
Fields
audio_url
: URL of the audio file to playtext
: Text description of the audiostatus
: Audio playback status (0: pause, 1: play)
AudioStatus
Current audio playback status.
pub struct AudioStatus {
pub start_time: Option<String>,
pub end_time: Option<String>,
pub status: Option<u32>,
}
Fields
start_time
: When audio playback startedend_time
: When audio playback endedstatus
: Current playback status
PublicAudio
Public audio channel information.
pub struct PublicAudio {
pub audio_type: Option<PublicAudioType>,
pub channel_id: Option<String>,
pub guild_id: Option<String>,
pub user_id: Option<String>,
}
Fields
audio_type
: Type of audio event (enter/exit)channel_id
: ID of the audio channelguild_id
: ID of the guilduser_id
: ID of the user involved
PublicAudioType
Audio channel event types.
pub enum PublicAudioType {
Enter = 1,
Exit = 2,
}
Variants
Enter
: User entered an audio channelExit
: User left an audio channel
Forum and Thread Types
Thread
Represents a forum thread.
pub struct Thread {
pub guild_id: String,
pub channel_id: String,
pub author_id: String,
pub thread_info: ThreadInfo,
}
Fields
guild_id
: ID of the guild containing the threadchannel_id
: ID of the forum channelauthor_id
: ID of the thread authorthread_info
: Detailed thread information
ThreadInfo
Detailed information about a thread.
pub struct ThreadInfo {
pub thread_id: String,
pub title: String,
pub content: String,
pub date_time: String,
}
Fields
thread_id
: Unique thread identifiertitle
: Thread titlecontent
: Thread content/descriptiondate_time
: Thread creation timestamp
OpenThread
Open forum thread with additional metadata.
pub struct OpenThread {
pub guild_id: String,
pub channel_id: String,
pub author_id: String,
pub thread_info: ThreadInfo,
pub task_id: Option<String>,
pub event_id: Option<String>,
}
Fields
guild_id
: Guild IDchannel_id
: Channel IDauthor_id
: Author IDthread_info
: Thread informationtask_id
: Associated task IDevent_id
: Event ID for tracking
Permission Types
Permission
Represents permissions for channels and roles.
pub struct Permission {
pub channel_id: String,
pub user_id: Option<String>,
pub role_id: Option<String>,
pub permissions: String,
}
Fields
channel_id
: Channel these permissions apply touser_id
: User ID (for user-specific permissions)role_id
: Role ID (for role-based permissions)permissions
: Permission bit flags as string
ChannelPermissions
Channel-specific permission configuration.
pub struct ChannelPermissions {
pub channel_id: String,
pub permissions: String,
}
Schedule Types
Schedule
Represents a scheduled event or task.
pub struct Schedule {
pub id: String,
pub name: String,
pub description: Option<String>,
pub start_timestamp: String,
pub end_timestamp: String,
pub creator: Option<Member>,
pub jump_channel_id: Option<String>,
pub remind_type: String,
}
Fields
id
: Unique schedule identifiername
: Schedule name/titledescription
: Optional descriptionstart_timestamp
: When the event startsend_timestamp
: When the event endscreator
: Member who created the schedulejump_channel_id
: Channel to direct users toremind_type
: Type of reminder notifications
Interaction Types
Interaction
Represents user interactions with bot components.
pub struct Interaction {
pub id: String,
pub application_id: String,
pub interaction_type: InteractionType,
pub data: Option<InteractionData>,
pub guild_id: Option<String>,
pub channel_id: Option<String>,
pub user: Option<User>,
pub member: Option<Member>,
pub token: String,
pub version: u32,
}
Fields
id
: Unique interaction identifierapplication_id
: Bot application IDinteraction_type
: Type of interactiondata
: Interaction-specific dataguild_id
: Guild where interaction occurredchannel_id
: Channel where interaction occurreduser
: User who triggered the interactionmember
: Member information if in guildtoken
: Interaction token for responsesversion
: API version
InteractionType
Types of user interactions.
pub enum InteractionType {
Ping = 1,
ApplicationCommand = 2,
MessageComponent = 3,
}
Variants
Ping
: Ping interaction for verificationApplicationCommand
: Slash command executionMessageComponent
: Button or select menu interaction
InteractionData
Data payload for interactions.
pub struct InteractionData {
pub data_type: InteractionDataType,
pub resolved: Option<serde_json::Value>,
}
Fields
data_type
: Type of interaction dataresolved
: Resolved entities (users, roles, channels, etc.)
Reaction Types
Reaction
Represents emoji reactions on messages.
pub struct Reaction {
pub target: ReactionTarget,
pub emoji_type: u32,
pub emoji_id: String,
}
Fields
target
: What the reaction is applied toemoji_type
: Type of emoji (1: system, 2: custom)emoji_id
: Emoji identifier
ReactionTarget
Target for emoji reactions.
pub struct ReactionTarget {
pub target_type: ReactionTargetType,
pub id: String,
}
Fields
target_type
: Type of target (message, etc.)id
: Target identifier
ReactionTargetType
Types of reaction targets.
pub enum ReactionTargetType {
Message = 0,
}
ReactionUsers
Users who reacted with a specific emoji.
pub struct ReactionUsers {
pub users: Vec<User>,
pub cookie: Option<String>,
pub is_end: Option<bool>,
}
Fields
users
: List of users who reactedcookie
: Pagination tokenis_end
: Whether this is the last page
Management Event Types
C2CManageEvent
Client-to-client management events.
pub struct C2CManageEvent {
pub event_type: ManageEventType,
pub timestamp: u64,
pub openid: String,
}
Fields
event_type
: Type of management eventtimestamp
: Event timestampopenid
: User's OpenID
GroupManageEvent
Group management events.
pub struct GroupManageEvent {
pub event_type: ManageEventType,
pub timestamp: u64,
pub group_openid: String,
pub op_member_openid: String,
}
Fields
event_type
: Type of management eventtimestamp
: Event timestampgroup_openid
: Group's OpenIDop_member_openid
: Operating member's OpenID
ManageEventType
Types of management events.
pub enum ManageEventType {
FriendAdd = 11001,
FriendDel = 11002,
C2cMsgReject = 11003,
C2cMsgReceive = 11004,
GroupAddRobot = 12001,
GroupDelRobot = 12002,
GroupMsgReject = 12003,
GroupMsgReceive = 12004,
}
Gateway Types
Ready
Ready event data when bot connects.
pub struct Ready {
pub version: u32,
pub session_id: String,
pub user: BotInfo,
pub shard: Option<[u32; 2]>,
}
Fields
version
: Gateway versionsession_id
: Session identifier for this connectionuser
: Bot user informationshard
: Shard information [shard_id, shard_count]
ConnectionSession
Session information for the gateway connection.
pub struct ConnectionSession {
pub session_id: String,
pub shard_id: u32,
pub shard_count: u32,
pub last_sequence: Option<u64>,
}
Fields
session_id
: Unique session identifiershard_id
: Current shard ID (0-based)shard_count
: Total number of shardslast_sequence
: Last received sequence number
ConnectionState
Current state of the gateway connection.
pub enum ConnectionState {
Disconnected,
Connecting,
Connected,
Reconnecting,
Closing,
}
Variants
Disconnected
: Not connected to gatewayConnecting
: Attempting to connectConnected
: Successfully connected and readyReconnecting
: Attempting to reconnect after disconnectClosing
: Gracefully closing connection
Utility Types
HasId
Trait for types that have an ID field.
pub trait HasId {
fn id(&self) -> &str;
}
This trait is implemented by most entities (messages, users, guilds, etc.) to provide a consistent way to access their identifier.
Session
Session management utilities.
pub struct Session {
pub url: String,
pub shards: u32,
pub session_start_limit: SessionStartLimit,
}
SessionStartLimit
Limits on session starts.
pub struct SessionStartLimit {
pub total: u32,
pub remaining: u32,
pub reset_after: u64,
pub max_concurrency: u32,
}
Common Usage Patterns
Audio Channel Management
async fn manage_audio_channel(ctx: Context, channel_id: &str) -> Result<()> {
// Play audio in channel
let audio_control = AudioControl {
audio_url: Some("https://example.com/audio.mp3".to_string()),
text: Some("Now playing background music".to_string()),
status: Some(1), // Play
};
ctx.update_audio(channel_id, &audio_control).await?;
println!("Started audio playback");
// Wait and then stop
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
let stop_control = AudioControl {
audio_url: None,
text: Some("Audio stopped".to_string()),
status: Some(0), // Pause
};
ctx.update_audio(channel_id, &stop_control).await?;
println!("Stopped audio playback");
Ok(())
}
Forum Thread Creation
async fn create_forum_thread(
ctx: Context,
channel_id: &str,
title: &str,
content: &str,
) -> Result<OpenThread> {
use botrs::forum::{Title, Content, Format};
let thread_title = Title {
text: title.to_string(),
paragraphs: vec![],
};
let thread_content = Content {
paragraphs: vec![content.to_string()],
};
let thread = ctx.api.create_thread(
&ctx.token,
channel_id,
&thread_title,
&thread_content,
&Format::Text,
).await?;
println!("Created forum thread: {}", thread.thread_info.title);
Ok(thread)
}
Reaction Management
async fn manage_reactions(ctx: Context, channel_id: &str, message_id: &str) -> Result<()> {
// Add reaction
let reaction = Reaction {
target: ReactionTarget {
target_type: ReactionTargetType::Message,
id: message_id.to_string(),
},
emoji_type: 1, // System emoji
emoji_id: "128077".to_string(), // Thumbs up
};
ctx.add_reaction(channel_id, message_id, &reaction).await?;
println!("Added thumbs up reaction");
// Get users who reacted
let reaction_users = ctx.get_reaction_users(
channel_id,
message_id,
&reaction,
None, // cookie
Some(50), // limit
).await?;
println!("Users who reacted:");
for user in reaction_users.users {
println!(" - {}", user.username.as_deref().unwrap_or("Unknown"));
}
// Remove reaction
ctx.remove_reaction(channel_id, message_id, &reaction).await?;
println!("Removed reaction");
Ok(())
}
Schedule Management
async fn create_schedule(
ctx: Context,
channel_id: &str,
name: &str,
description: &str,
start_time: &str,
end_time: &str,
) -> Result<()> {
let schedule = Schedule {
id: String::new(), // Will be assigned by server
name: name.to_string(),
description: Some(description.to_string()),
start_timestamp: start_time.to_string(),
end_timestamp: end_time.to_string(),
creator: None,
jump_channel_id: Some(channel_id.to_string()),
remind_type: "1".to_string(), // Remind before start
};
// Note: Actual schedule creation would need appropriate API call
println!("Schedule created: {}", schedule.name);
Ok(())
}
Permission Checking
async fn check_user_permissions(
ctx: Context,
channel_id: &str,
user_id: &str,
) -> Result<bool> {
let permissions = ctx.get_channel_user_permissions(channel_id, user_id).await?;
// Parse permission string (this is simplified)
let perm_value: u64 = permissions.permissions.parse().unwrap_or(0);
// Check for specific permissions (bit flags)
const SEND_MESSAGES: u64 = 1 << 11;
const READ_MESSAGE_HISTORY: u64 = 1 << 16;
let can_send = (perm_value & SEND_MESSAGES) != 0;
let can_read_history = (perm_value & READ_MESSAGE_HISTORY) != 0;
println!("User permissions in channel:");
println!(" Can send messages: {}", can_send);
println!(" Can read history: {}", can_read_history);
Ok(can_send && can_read_history)
}
See Also
- Client API - Main client for bot operations
- Messages - Message types and handling
- Guilds & Channels - Guild and channel management
- Users & Members - User and member management