botrs 0.2.7

A Rust QQ Bot framework based on QQ Guild Bot API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
# BotApi API Reference

The `BotApi` struct provides direct access to QQ Guild's REST API endpoints. It handles HTTP requests, authentication, and response parsing for all bot operations.

## Overview

```rust
use botrs::{BotApi, Token, Result};

// Create API client
let api = BotApi::new(http_client);

// Use with token
let token = Token::new("app_id", "secret");
let bot_info = api.get_bot_info(&token).await?;
```

The `BotApi` is the core interface for making HTTP requests to QQ Guild's API. It provides methods for:

- Bot information and authentication
- Guild and channel management
- Message operations
- Member management
- Audio and voice controls
- File uploads and media
- Permissions and roles

## Constructor

### `new`

Creates a new BotApi instance.

```rust
pub fn new(http: HttpClient) -> Self
```

#### Parameters

- `http`: The HTTP client to use for requests

#### Example

```rust
use botrs::{BotApi, HttpClient};

let http = HttpClient::new(30, false)?;
let api = BotApi::new(http);
```

## Bot Information

### `get_bot_info`

Gets information about the current bot.

```rust
pub async fn get_bot_info(&self, token: &Token) -> Result<BotInfo>
```

#### Parameters

- `token`: Authentication token

#### Returns

Bot information including username, ID, and other details.

#### Example

```rust
let bot_info = api.get_bot_info(&token).await?;
println!("Bot: {} (ID: {})", bot_info.username, bot_info.id);
```

### `get_gateway`

Gets the WebSocket gateway URL for real-time events.

```rust
pub async fn get_gateway(&self, token: &Token) -> Result<GatewayResponse>
```

#### Parameters

- `token`: Authentication token

#### Returns

Gateway information including WebSocket URL and connection details.

#### Example

```rust
let gateway = api.get_gateway(&token).await?;
println!("Gateway URL: {}", gateway.url);
```

## Guild Operations

### `get_guild`

Gets detailed information about a specific guild.

```rust
pub async fn get_guild(&self, token: &Token, guild_id: &str) -> Result<Guild>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild ID to retrieve

#### Returns

Complete guild information including channels, roles, and settings.

#### Example

```rust
let guild = api.get_guild(&token, "guild_123").await?;
println!("Guild: {} with {} members", guild.name, guild.member_count);
```

### `get_guilds`

Gets a list of guilds the bot is in.

```rust
pub async fn get_guilds(&self, token: &Token) -> Result<Vec<Guild>>
```

#### Parameters

- `token`: Authentication token

#### Returns

List of guilds the bot has access to.

#### Example

```rust
let guilds = api.get_guilds(&token).await?;
for guild in guilds {
    println!("Guild: {} ({})", guild.name, guild.id);
}
```

## Channel Operations

### `get_channel`

Gets information about a specific channel.

```rust
pub async fn get_channel(&self, token: &Token, channel_id: &str) -> Result<Channel>
```

#### Parameters

- `token`: Authentication token
- `channel_id`: The channel ID to retrieve

#### Returns

Channel information including name, type, and permissions.

#### Example

```rust
let channel = api.get_channel(&token, "channel_123").await?;
println!("Channel: {} (Type: {:?})", channel.name, channel.type_);
```

### `get_channels`

Gets all channels in a guild.

```rust
pub async fn get_channels(&self, token: &Token, guild_id: &str) -> Result<Vec<Channel>>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild ID to get channels from

#### Returns

List of channels in the guild.

#### Example

```rust
let channels = api.get_channels(&token, "guild_123").await?;
for channel in channels {
    println!("Channel: {} ({})", channel.name, channel.id);
}
```

### `create_channel`

Creates a new channel in a guild.

```rust
pub async fn create_channel(
    &self,
    token: &Token,
    guild_id: &str,
    channel: CreateChannel,
) -> Result<Channel>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild to create the channel in
- `channel`: Channel creation parameters

#### Returns

The created channel information.

#### Example

```rust
use botrs::{CreateChannel, ChannelType, ChannelSubType};

let new_channel = CreateChannel {
    name: "new-text-channel".to_string(),
    type_: ChannelType::Text,
    sub_type: ChannelSubType::Chat,
    position: None,
    parent_id: None,
    private_type: None,
    private_user_ids: None,
    speak_permission: None,
    application_id: None,
};

let channel = api.create_channel(&token, "guild_123", new_channel).await?;
println!("Created channel: {}", channel.name);
```

### `update_channel`

Updates an existing channel.

```rust
pub async fn update_channel(
    &self,
    token: &Token,
    channel_id: &str,
    update: UpdateChannel,
) -> Result<Channel>
```

#### Parameters

- `token`: Authentication token
- `channel_id`: The channel to update
- `update`: Channel update parameters

#### Returns

The updated channel information.

### `delete_channel`

Deletes a channel.

```rust
pub async fn delete_channel(&self, token: &Token, channel_id: &str) -> Result<()>
```

#### Parameters

- `token`: Authentication token
- `channel_id`: The channel to delete

#### Example

```rust
api.delete_channel(&token, "channel_123").await?;
println!("Channel deleted");
```

## Message Operations

### `get_message`

Gets a specific message by ID.

```rust
pub async fn get_message(
    &self,
    token: &Token,
    channel_id: &str,
    message_id: &str,
) -> Result<Message>
```

#### Parameters

- `token`: Authentication token
- `channel_id`: The channel containing the message
- `message_id`: The message ID to retrieve

#### Returns

The message data.

#### Example

```rust
let message = api.get_message(&token, "channel_123", "msg_456").await?;
println!("Message: {}", message.content.unwrap_or_default());
```

### `post_message_with_params`

Sends a message using structured parameters.

```rust
pub async fn post_message_with_params(
    &self,
    token: &Token,
    channel_id: &str,
    params: MessageParams,
) -> Result<Message>
```

#### Parameters

- `token`: Authentication token
- `channel_id`: The channel to send the message to
- `params`: Message parameters including content, embeds, files, etc.

#### Returns

The sent message data.

#### Example

```rust
use botrs::MessageParams;

let params = MessageParams::new_text("Hello, world!")
    .with_reply("original_msg_id")
    .with_markdown(true);

let message = api.post_message_with_params(&token, "channel_123", params).await?;
println!("Message sent: {}", message.id);
```

### `post_message`

Sends a simple text message (legacy method).

```rust
pub async fn post_message(
    &self,
    token: &Token,
    channel_id: &str,
    content: Option<&str>,
    embed: Option<MessageEmbed>,
    ark: Option<MessageArk>,
    reference: Option<MessageReference>,
    image: Option<&str>,
    msg_id: Option<&str>,
    event_id: Option<&str>,
    markdown: Option<MarkdownParams>,
    keyboard: Option<MessageKeyboard>,
    media: Option<FileInfo>,
) -> Result<Message>
```

**Note**: This method is deprecated. Use `post_message_with_params` instead.

### `recall_message`

Recalls (deletes) a message.

```rust
pub async fn recall_message(
    &self,
    token: &Token,
    channel_id: &str,
    message_id: &str,
    hidetip: bool,
) -> Result<()>
```

#### Parameters

- `token`: Authentication token
- `channel_id`: The channel containing the message
- `message_id`: The message to recall
- `hidetip`: Whether to hide the deletion notification

#### Example

```rust
api.recall_message(&token, "channel_123", "msg_456", false).await?;
println!("Message recalled");
```

## Direct Messages

### `create_dms`

Creates a direct message session.

```rust
pub async fn create_dms(
    &self,
    token: &Token,
    create_dms: CreateDirectMessageGuild,
) -> Result<DirectMessageGuild>
```

#### Parameters

- `token`: Authentication token
- `create_dms`: Parameters for creating the DM session

#### Returns

Direct message guild information.

#### Example

```rust
use botrs::CreateDirectMessageGuild;

let create_dm = CreateDirectMessageGuild {
    recipient_id: "user_123".to_string(),
    source_guild_id: "guild_456".to_string(),
};

let dm_guild = api.create_dms(&token, create_dm).await?;
println!("DM session created: {}", dm_guild.guild_id);
```

### `post_dms_with_params`

Sends a direct message using structured parameters.

```rust
pub async fn post_dms_with_params(
    &self,
    token: &Token,
    guild_id: &str,
    params: MessageParams,
) -> Result<Message>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The DM guild ID
- `params`: Message parameters

#### Returns

The sent direct message.

## Group and C2C Messages

### `post_group_message_with_params`

Sends a group message using structured parameters.

```rust
pub async fn post_group_message_with_params(
    &self,
    token: &Token,
    group_openid: &str,
    params: GroupMessageParams,
) -> Result<Message>
```

#### Parameters

- `token`: Authentication token
- `group_openid`: The group identifier
- `params`: Group message parameters

#### Returns

The sent group message.

### `post_c2c_message_with_params`

Sends a C2C (client-to-client) message using structured parameters.

```rust
pub async fn post_c2c_message_with_params(
    &self,
    token: &Token,
    openid: &str,
    params: C2CMessageParams,
) -> Result<Message>
```

#### Parameters

- `token`: Authentication token
- `openid`: The user identifier
- `params`: C2C message parameters

#### Returns

The sent C2C message.

## Member Management

### `get_guild_member`

Gets information about a specific guild member.

```rust
pub async fn get_guild_member(
    &self,
    token: &Token,
    guild_id: &str,
    user_id: &str,
) -> Result<Member>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild ID
- `user_id`: The user ID

#### Returns

Member information including roles and permissions.

#### Example

```rust
let member = api.get_guild_member(&token, "guild_123", "user_456").await?;
println!("Member: {}", member.nick.unwrap_or_default());
```

### `get_guild_members`

Gets a list of guild members with pagination.

```rust
pub async fn get_guild_members(
    &self,
    token: &Token,
    guild_id: &str,
    query: Option<&MemberQuery>,
) -> Result<Vec<Member>>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild ID
- `query`: Optional query parameters for pagination and filtering

#### Returns

List of guild members.

#### Example

```rust
use botrs::MemberQuery;

let query = MemberQuery {
    after: None,
    limit: Some(100),
};

let members = api.get_guild_members(&token, "guild_123", Some(&query)).await?;
println!("Found {} members", members.len());
```

### `delete_member`

Removes a member from the guild.

```rust
pub async fn delete_member(
    &self,
    token: &Token,
    guild_id: &str,
    user_id: &str,
    add_blacklist: bool,
    delete_history_msg_days: Option<u8>,
    reason: Option<&str>,
) -> Result<()>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild ID
- `user_id`: The user to remove
- `add_blacklist`: Whether to add to blacklist
- `delete_history_msg_days`: Days of message history to delete
- `reason`: Reason for removal

#### Example

```rust
api.delete_member(
    &token,
    "guild_123",
    "user_456",
    false,
    Some(7),
    Some("Violated community guidelines")
).await?;
```

## Role Management

### `get_guild_roles`

Gets all roles in a guild.

```rust
pub async fn get_guild_roles(&self, token: &Token, guild_id: &str) -> Result<GuildRoles>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild ID

#### Returns

Guild roles information.

#### Example

```rust
let roles = api.get_guild_roles(&token, "guild_123").await?;
for role in &roles.roles {
    println!("Role: {} (ID: {})", role.name, role.id);
}
```

### `create_guild_role`

Creates a new role in a guild.

```rust
pub async fn create_guild_role(
    &self,
    token: &Token,
    guild_id: &str,
    role: CreateRole,
) -> Result<CreateRoleResponse>
```

#### Parameters

- `token`: Authentication token
- `guild_id`: The guild ID
- `role`: Role creation parameters

#### Returns

The created role information.

#### Example

```rust
use botrs::CreateRole;

let new_role = CreateRole {
    name: "Moderator".to_string(),
    color: Some(0x9932cc),
    hoist: Some(true),
    mentionable: Some(true),
};

let role = api.create_guild_role(&token, "guild_123", new_role).await?;
println!("Created role: {}", role.role.name);
```

### `update_guild_role`

Updates an existing guild role.

```rust
pub async fn update_guild_role(
    &self,
    token: &Token,
    guild_id: &str,
    role_id: &str,
    role: UpdateRole,
) -> Result<UpdateRoleResponse>
```

### `delete_guild_role`

Deletes a guild role.

```rust
pub async fn delete_guild_role(
    &self,
    token: &Token,
    guild_id: &str,
    role_id: &str,
) -> Result<()>
```

### `create_guild_role_member`

Assigns a role to a guild member.

```rust
pub async fn create_guild_role_member(
    &self,
    token: &Token,
    guild_id: &str,
    role_id: &str,
    user_id: &str,
    channel: Option<MemberAddRoleChannel>,
) -> Result<()>
```

### `delete_guild_role_member`

Removes a role from a guild member.

```rust
pub async fn delete_guild_role_member(
    &self,
    token: &Token,
    guild_id: &str,
    role_id: &str,
    user_id: &str,
    channel: Option<MemberAddRoleChannel>,
) -> Result<()>
```

## Audio and Voice

### `update_audio`

Updates audio playback in a voice channel.

```rust
pub async fn update_audio(
    &self,
    token: &Token,
    channel_id: &str,
    audio_control: AudioControl,
) -> Result<()>
```

#### Parameters

- `token`: Authentication token
- `channel_id`: The voice channel ID
- `audio_control`: Audio control parameters

#### Example

```rust
use botrs::{AudioControl, AudioStatus};

let audio_control = AudioControl {
    audio_url: "https://example.com/audio.mp3".to_string(),
    text: "Now playing music".to_string(),
    status: AudioStatus::Start,
};

api.update_audio(&token, "channel_123", audio_control).await?;
```

### `on_microphone`

Enables microphone for a user in voice channel.

```rust
pub async fn on_microphone(
    &self,
    token: &Token,
    channel_id: &str,
    user_id: &str,
) -> Result<()>
```

### `off_microphone`

Disables microphone for a user in voice channel.

```rust
pub async fn off_microphone(
    &self,
    token: &Token,
    channel_id: &str,
    user_id: &str,
) -> Result<()>
```

### `mute_all`

Mutes all users in a voice channel.

```rust
pub async fn mute_all(&self, token: &Token, channel_id: &str) -> Result<()>
```

### `cancel_mute_all`

Unmutes all users in a voice channel.

```rust
pub async fn cancel_mute_all(&self, token: &Token, channel_id: &str) -> Result<()>
```

### `mute_member`

Mutes a specific member in a voice channel.

```rust
pub async fn mute_member(
    &self,
    token: &Token,
    guild_id: &str,
    user_id: &str,
    mute_end_timestamp: Option<&str>,
    mute_seconds: Option<&str>,
) -> Result<()>
```

## File Operations

### `post_group_file`

Uploads a file to a group.

```rust
pub async fn post_group_file(
    &self,
    token: &Token,
    group_openid: &str,
    file_type: u8,
    file_data: &[u8],
) -> Result<FileInfo>
```

#### Parameters

- `token`: Authentication token
- `group_openid`: The group identifier
- `file_type`: Type of file being uploaded
- `file_data`: The file content as bytes

#### Returns

Information about the uploaded file.

### `post_c2c_file`

Uploads a file for C2C messaging.

```rust
pub async fn post_c2c_file(
    &self,
    token: &Token,
    openid: &str,
    file_type: u8,
    file_data: &[u8],
) -> Result<FileInfo>
```

## Permissions

### `get_permissions`

Gets API permissions for the bot.

```rust
pub async fn get_permissions(&self, token: &Token, guild_id: &str) -> Result<ApiPermissions>
```

### `post_permission_demand`

Requests additional API permissions.

```rust
pub async fn post_permission_demand(
    &self,
    token: &Token,
    guild_id: &str,
    demand: PermissionDemandRequest,
) -> Result<()>
```

### `get_channel_user_permissions`

Gets user permissions for a specific channel.

```rust
pub async fn get_channel_user_permissions(
    &self,
    token: &Token,
    channel_id: &str,
    user_id: &str,
) -> Result<ChannelPermissions>
```

### `get_channel_role_permissions`

Gets role permissions for a specific channel.

```rust
pub async fn get_channel_role_permissions(
    &self,
    token: &Token,
    channel_id: &str,
    role_id: &str,
) -> Result<ChannelPermissions>
```

## Reactions and Pins

### `put_reaction`

Adds a reaction to a message.

```rust
pub async fn put_reaction(
    &self,
    token: &Token,
    channel_id: &str,
    message_id: &str,
    emoji: ReactionEmoji,
) -> Result<()>
```

### `delete_reaction`

Removes a reaction from a message.

```rust
pub async fn delete_reaction(
    &self,
    token: &Token,
    channel_id: &str,
    message_id: &str,
    emoji: ReactionEmoji,
) -> Result<()>
```

### `get_reaction_users`

Gets users who reacted with a specific emoji.

```rust
pub async fn get_reaction_users(
    &self,
    token: &Token,
    channel_id: &str,
    message_id: &str,
    emoji: ReactionEmoji,
    query: Option<ReactionUsersQuery>,
) -> Result<ReactionUsers>
```

### `put_pin`

Pins a message in a channel.

```rust
pub async fn put_pin(
    &self,
    token: &Token,
    channel_id: &str,
    message_id: &str,
) -> Result<PinMessage>
```

### `delete_pin`

Unpins a message in a channel.

```rust
pub async fn delete_pin(
    &self,
    token: &Token,
    channel_id: &str,
    message_id: &str,
) -> Result<()>
```

### `get_pins`

Gets all pinned messages in a channel.

```rust
pub async fn get_pins(&self, token: &Token, channel_id: &str) -> Result<PinMessages>
```

## Utility Methods

### `http`

Gets a reference to the underlying HTTP client.

```rust
pub fn http(&self) -> &HttpClient
```

### `close`

Closes the API client and releases resources.

```rust
pub async fn close(&self)
```

## Error Handling

All API methods return `Result<T, BotError>`. Common error scenarios include:

- **Authentication errors**: Invalid token or insufficient permissions
- **Rate limiting**: Too many requests in a short time
- **Not found errors**: Resource doesn't exist
- **Network errors**: Connection problems or timeouts

### Example Error Handling

```rust
use botrs::BotError;

match api.get_guild(&token, "invalid_guild").await {
    Ok(guild) => println!("Guild: {}", guild.name),
    Err(BotError::NotFound(msg)) => println!("Guild not found: {}", msg),
    Err(BotError::RateLimit { retry_after }) => {
        println!("Rate limited, retry after {} seconds", retry_after);
    }
    Err(e) => eprintln!("API error: {}", e),
}
```

## Best Practices

### Performance

1. **Reuse API instances**: Create one `BotApi` instance and reuse it
2. **Handle rate limits**: Implement proper backoff for rate-limited requests
3. **Use structured parameters**: Prefer `*_with_params` methods over legacy variants
4. **Batch operations**: Group related API calls when possible

### Error Handling

1. **Check permissions**: Verify bot has necessary permissions before API calls
2. **Validate inputs**: Check parameters before making requests
3. **Implement retries**: Retry transient failures with exponential backoff
4. **Log errors**: Record API errors for debugging and monitoring

### Security

1. **Protect tokens**: Never log or expose authentication tokens
2. **Validate user input**: Sanitize user-provided data before API calls
3. **Respect permissions**: Don't attempt operations the bot isn't authorized for
4. **Rate limit protection**: Implement client-side rate limiting

## See Also

- [`Client`]./client.md - High-level bot client
- [`Context`]./context.md - API access in event handlers
- [`Message Types`]./models/messages.md - Message data structures
- [`Error Types`]./error-types.md - Error handling and types