# 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 an audio gateway event.
```rust
pub struct Audio {
pub event_id: Option<String>,
pub channel_id: Option<String>,
pub guild_id: Option<String>,
pub audio_url: Option<String>,
pub text: Option<String>,
}
```
#### Fields
- `event_id`: Gateway event ID
- `channel_id`: ID of the voice channel
- `guild_id`: ID of the guild
- `audio_url`: URL of the audio file
- `text`: Text description of the audio
### `AudioControl`
Audio control operations.
```rust
pub struct AudioControl {
pub audio_url: String,
pub text: String,
pub status: AudioStatus,
}
```
#### Fields
- `audio_url`: URL of the audio file to play
- `text`: Text description of the audio
- `status`: Audio playback status
### `AudioStatus`
Audio playback status.
```rust
pub enum AudioStatus {
Start = 0,
Pause = 1,
Resume = 2,
Stop = 3,
}
```
#### Variants
- `Start`: Start playback
- `Pause`: Pause playback
- `Resume`: Resume playback
- `Stop`: Stop playback
### `PublicAudio`
Public audio channel information.
```rust
pub struct PublicAudio {
pub guild_id: Option<String>,
pub channel_id: Option<String>,
pub channel_type: Option<PublicAudioType>,
pub user_id: Option<String>,
}
```
#### Fields
- `guild_id`: ID of the guild
- `channel_id`: ID of the audio channel
- `channel_type`: Type of audio channel
- `user_id`: ID of the user involved
### `PublicAudioType`
Audio channel type.
```rust
pub enum PublicAudioType {
Voice = 2,
Live = 5,
}
```
#### Variants
- `Enter`: User entered an audio channel
- `Exit`: User left an audio channel
## Forum and Thread Types
### `Thread`
Represents a forum thread.
```rust
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 thread
- `channel_id`: ID of the forum channel
- `author_id`: ID of the thread author
- `thread_info`: Detailed thread information
### `ThreadInfo`
Detailed information about a thread.
```rust
pub struct ThreadInfo {
pub thread_id: Option<String>,
pub title: Option<String>,
pub content: Option<String>,
pub date_time: Option<String>,
}
```
#### Fields
- `thread_id`: Unique thread identifier
- `title`: Thread title string from the botgo DTO
- `content`: Thread content string from the botgo DTO
- `date_time`: Thread creation timestamp
### `OpenThread`
Open forum thread with additional metadata.
```rust
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 ID
- `channel_id`: Channel ID
- `author_id`: Author ID
- `thread_info`: Thread information
- `task_id`: Associated task ID
- `event_id`: Event ID for tracking
## Permission Types
### `Permission`
Represents permissions for channels and roles.
```rust
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 to
- `user_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.
```rust
pub struct ChannelPermissions {
pub channel_id: String,
pub permissions: String,
}
```
## Schedule Types
### `Schedule`
Represents a scheduled event or task.
```rust
pub struct Schedule {
pub id: String,
pub name: String,
pub description: String,
pub start_timestamp: String,
pub end_timestamp: String,
pub creator: Option<Member>,
pub jump_channel_id: String,
pub remind_type: String,
}
```
#### Fields
- `id`: Unique schedule identifier
- `name`: Schedule name/title
- `description`: Schedule description
- `start_timestamp`: When the event starts
- `end_timestamp`: When the event ends
- `creator`: Member who created the schedule
- `jump_channel_id`: Channel to direct users to
- `remind_type`: Type of reminder notifications
## Interaction Types
### `Interaction`
Represents user interactions with bot components.
```rust
pub struct Interaction {
pub id: Option<String>,
pub application_id: Option<String>,
pub interaction_type: Option<InteractionType>,
pub data: InteractionData,
pub guild_id: Option<String>,
pub channel_id: Option<String>,
pub group_openid: Option<String>,
pub chat_type: Option<u64>,
pub scene: Option<String>,
pub user_openid: Option<String>,
pub timestamp: Option<String>,
pub group_member_openid: Option<String>,
pub version: Option<u64>,
}
```
#### Fields
- `id`: Unique interaction identifier
- `application_id`: Bot application ID
- `interaction_type`: Type of interaction
- `data`: Interaction-specific data
- `guild_id`: Guild where interaction occurred
- `channel_id`: Channel where interaction occurred
- `version`: API version
### `InteractionType`
Types of user interactions.
```rust
pub enum InteractionType {
Ping = 1,
ApplicationCommand = 2,
HttpProxy = 10,
InlineKeyboard = 11,
}
```
#### Variants
- `Ping`: Ping interaction for verification
- `ApplicationCommand`: Slash command execution
- `HttpProxy`: HTTP proxy interaction
- `InlineKeyboard`: Inline keyboard interaction
### `InteractionData`
Data payload for interactions.
```rust
pub struct InteractionData {
pub name: String,
pub data_type: Option<InteractionDataType>,
pub resolved: Resolved,
}
```
#### Fields
- `data_type`: Type of interaction data
- `resolved`: Resolved entities (users, roles, channels, etc.)
## Reaction Types
### `MessageReaction`
Botgo-compatible gateway DTO for message reaction events.
```rust
pub struct MessageReaction {
pub user_id: String,
pub channel_id: String,
pub guild_id: String,
pub target: ReactionTarget,
pub emoji: ReactionEmoji,
}
```
### `Reaction`
Event helper built from `MessageReaction`, with `api()` and `event_id`.
```rust
pub struct Reaction {
pub user_id: String,
pub channel_id: String,
pub guild_id: String,
pub target: ReactionTarget,
pub emoji: ReactionEmoji,
pub event_id: Option<String>,
}
```
#### Fields
- `user_id`: User who made the reaction
- `channel_id`: Channel where the reaction occurred
- `guild_id`: Guild where the reaction occurred
- `target`: What the reaction is applied to
- `emoji`: Emoji identifier and type
### `ReactionTarget`
Target for emoji reactions.
```rust
pub struct ReactionTarget {
pub id: String,
pub target_type: ReactionTargetType,
}
```
#### Fields
- `target_type`: Type of target (message, etc.)
- `id`: Target identifier
### `ReactionTargetType`
Types of reaction targets.
```rust
pub enum ReactionTargetType {
Message = 0,
Post = 1,
Comment = 2,
Reply = 3,
}
```
### `ReactionEmoji`
Emoji object used by botgo-compatible reaction APIs.
```rust
pub struct ReactionEmoji {
pub id: String,
pub emoji_type: i32,
}
```
### `ReactionUsers`
Users who reacted with a specific emoji.
```rust
pub struct ReactionUsers {
pub users: Vec<User>,
pub cookie: Option<String>,
pub is_end: bool,
}
```
#### Fields
- `users`: List of users who reacted
- `cookie`: Pagination token
- `is_end`: Whether this is the last page
## Management Event Types
### `C2CManageEvent`
Client-to-client management events.
```rust
pub struct C2CManageEvent {
pub event_type: ManageEventType,
pub timestamp: u64,
pub openid: String,
}
```
#### Fields
- `event_type`: Type of management event
- `timestamp`: Event timestamp
- `openid`: User's OpenID
### `GroupManageEvent`
Group management events.
```rust
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 event
- `timestamp`: Event timestamp
- `group_openid`: Group's OpenID
- `op_member_openid`: Operating member's OpenID
### `ManageEventType`
Types of management events.
```rust
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.
```rust
pub struct Ready {
pub version: u32,
pub session_id: String,
pub user: BotInfo,
pub shard: Option<[u32; 2]>,
}
```
#### Fields
- `version`: Gateway version
- `session_id`: Session identifier for this connection
- `user`: Bot user information
- `shard`: Shard information [shard_id, shard_count]
### `ConnectionSession`
Session information for the gateway connection.
```rust
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 identifier
- `shard_id`: Current shard ID (0-based)
- `shard_count`: Total number of shards
- `last_sequence`: Last received sequence number
### `ConnectionState`
Current state of the gateway connection.
```rust
pub enum ConnectionState {
Disconnected,
Connecting,
Connected,
Reconnecting,
Closing,
}
```
#### Variants
- `Disconnected`: Not connected to gateway
- `Connecting`: Attempting to connect
- `Connected`: Successfully connected and ready
- `Reconnecting`: Attempting to reconnect after disconnect
- `Closing`: Gracefully closing connection
## Utility Types
### `HasId`
Trait for types that have an ID field.
```rust
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.
```rust
pub struct Session {
pub url: String,
pub shards: u32,
pub session_start_limit: SessionStartLimit,
}
```
### `SessionStartLimit`
Limits on session starts.
```rust
pub struct SessionStartLimit {
pub total: u32,
pub remaining: u32,
pub reset_after: u32,
pub max_concurrency: u32,
}
```
## Common Usage Patterns
### Audio Channel Management
```rust
async fn manage_audio_channel(ctx: Context, channel_id: &str) -> Result<()> {
// Play audio in channel
let audio_control = AudioControl {
audio_url: "https://example.com/audio.mp3".to_string(),
text: "Now playing background music".to_string(),
status: AudioStatus::Start,
};
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: String::new(),
text: "Audio stopped".to_string(),
status: AudioStatus::Stop,
};
ctx.update_audio(channel_id, &stop_control).await?;
println!("Stopped audio playback");
Ok(())
}
```
### Forum Thread Creation
```rust
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.as_deref().unwrap_or("Untitled")
);
Ok(thread)
}
```
### Reaction Management
```rust
async fn manage_reactions(ctx: Context, channel_id: &str, message_id: &str) -> Result<()> {
let emoji = ReactionEmoji::new("4", 1);
// Add reaction
ctx.create_message_reaction(channel_id, message_id, &emoji).await?;
println!("Added thumbs up reaction");
// Get users who reacted
let pager = MessageReactionPager::new(None::<String>, Some(50));
let reaction_users = ctx.get_message_reaction_users(
channel_id,
message_id,
&emoji,
&pager,
).await?;
println!("Users who reacted:");
for user in reaction_users.users {
println!(" - {}", user.username);
}
// Remove reaction
ctx.delete_own_message_reaction(channel_id, message_id, &emoji).await?;
println!("Removed reaction");
Ok(())
}
```
### Schedule Management
```rust
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: description.to_string(),
start_timestamp: start_time.to_string(),
end_timestamp: end_time.to_string(),
creator: None,
jump_channel_id: 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
```rust
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](../client.md) - Main client for bot operations
- [Messages](./messages.md) - Message types and handling
- [Guilds & Channels](./guilds-channels.md) - Guild and channel management
- [Users & Members](./users-members.md) - User and member management