#[cfg(windows)]
mod windows;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "linux")]
mod linux;
#[derive(Debug)]
pub struct DiscoveredToken {
pub token: String,
pub source: String,
pub username: String,
}
#[cfg(windows)]
pub async fn find_and_save_token() -> anyhow::Result<DiscoveredToken> {
windows::find_and_save_token().await
}
#[cfg(target_os = "macos")]
pub async fn find_and_save_token() -> anyhow::Result<DiscoveredToken> {
macos::find_and_save_token().await
}
#[cfg(target_os = "linux")]
pub async fn find_and_save_token() -> anyhow::Result<DiscoveredToken> {
linux::find_and_save_token().await
}
#[cfg(not(any(windows, target_os = "macos", target_os = "linux")))]
pub async fn find_and_save_token() -> anyhow::Result<DiscoveredToken> {
anyhow::bail!(
"auth --save is currently unsupported on this platform. \
Please set $DISCORD_TOKEN or pass --token <T>."
)
}