Skip to content

Commit

Permalink
Merge pull request #27 from traPtitech/fix-example
Browse files Browse the repository at this point in the history
📝 Fix example
  • Loading branch information
H1rono authored Jul 30, 2024
2 parents 1801ad4 + 564db98 commit f53385b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ This crate is updated using [openapi-generator](https://openapi-generator.tech).
Add this crate using `cargo add traq`, then write in `main.rs`:

```rust
use std::{env::var, error::Error};
use traq::apis::{channel_api, configuration};

#[tokio::main]
async fn main() {
async fn main() -> Result<(), Box<dyn Error>> {
let access_token = var("BOT_ACCESS_TOKEN")?;
let conf = configuration::Configuration {
bearer_access_token: env::var("BOT_ACCESS_TOKEN").ok(),
bearer_access_token: Some(access_token),
..Default::default()
};
let res = channel_api::get_channels(&conf, Some(true)).await;
println!("{:?}", res);
let channels = channel_api::get_channels(&conf, Some(true)).await?;
println!("there are {} public channels", channels.public.len());
Ok(())
}
```

Expand Down

0 comments on commit f53385b

Please sign in to comment.