From ea90b5ce89b9babb4ebc86de523efc7fa9631281 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Mon, 15 Jan 2024 20:39:23 -0600 Subject: Initial commit --- src/main.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main.rs (limited to 'src') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..0d602af --- /dev/null +++ b/src/main.rs @@ -0,0 +1,46 @@ +use anyhow::{Context, Result}; +use clap::Parser; +use serde::Deserialize; +use serenity::{ + all::{ActivityData, ActivityType, GatewayIntents, OnlineStatus}, + Client, +}; +use std::{fs, path::PathBuf}; + +#[derive(Debug, Deserialize)] +struct Config { + discord_token: String, +} + +#[derive(Debug, Parser)] +struct Args { + config_path: PathBuf, +} + +#[tokio::main] +async fn main() -> Result<()> { + let args = Args::parse(); + let config_str = fs::read_to_string(&args.config_path) + .with_context(|| format!("failed to read {}", args.config_path.display()))?; + let config: Config = toml::from_str(&config_str) + .with_context(|| format!("failed to parse {}", args.config_path.display()))?; + drop(config_str); + + let mut client = Client::builder(&config.discord_token, GatewayIntents::default()) + .activity(ActivityData { + name: "(λx → x x)(λx → x x)".to_string(), + kind: ActivityType::Custom, + state: Some("pondering".to_string()), + url: None, + }) + .status(OnlineStatus::Online) + .await + .context("failed to create Discord client")?; + + client + .start() + .await + .context("failed to start Discord client")?; + + Ok(()) +} -- cgit v1.2.3