initial implementation

This commit is contained in:
2022-05-23 15:39:57 +02:00
commit 141d97d278
5 changed files with 1614 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
use serenity::prelude::*;
use spamcontest::Handler;
use std::{env, process};
const TOKEN_VAR_KEY: &str = "DISCORD_TOKEN";
#[tokio::main]
async fn main() {
let token = match env::var(TOKEN_VAR_KEY) {
Ok(token) => token,
Err(err) => {
eprintln!("Unable to get {}: {}", TOKEN_VAR_KEY, err);
process::exit(1)
}
};
let intents = GatewayIntents::non_privileged() | GatewayIntents::MESSAGE_CONTENT;
let mut client = match Client::builder(token, intents)
.event_handler(Handler::new())
.await
{
Ok(client) => client,
Err(err) => {
eprintln!("Unable to start client: {}", err);
process::exit(2)
}
};
if let Err(err) = client.start().await {
eprintln!("An Error occurred while running the client: {:?}", err)
}
}