aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs46
1 files changed, 46 insertions, 0 deletions
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(())
+}