MCPcopy Create free account
hub / github.com/Botloader/botloader / login

Function login

cmd/blcmd/src/main.rs:95–118  ·  view source on GitHub ↗
(ctx: Context)

Source from the content-addressed store, hash-verified

93}
94
95async fn login(ctx: Context) -> anyhow::Result<()> {
96 println!("Enter your api token:");
97
98 let stdin = std::io::stdin();
99 let mut s = String::new();
100 let _ = stdin.read_line(&mut s)?;
101
102 let mut new_config = ctx.config;
103 new_config.api_token = s.trim().to_owned();
104
105 // try the token
106 let new_client = new_config.api_client();
107 let self_user = new_client.get_self_user().await?;
108
109 println!(
110 "Logged in as {}#{}!",
111 self_user.name,
112 self_user.discriminator()
113 );
114
115 confy::store(APP_NAME, &new_config)?;
116
117 Ok(())
118}
119
120async fn check_login(ctx: Context) -> anyhow::Result<()> {
121 if ctx.config.api_token.is_empty() {

Callers 1

mainFunction · 0.85

Calls 2

api_clientMethod · 0.80
get_self_userMethod · 0.80

Tested by

no test coverage detected