diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..971250b --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# Irrelevant macOS meta file +.DS_Store + +# Config file for private bot information +src/config.rs \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..bbaa962 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "among-us-discord-bot" +version = "0.1.0" +authors = ["Blake Wyatt "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serenity = "0.9.0-rc.1" +tokio = "0.2.22" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..40799f6 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,51 @@ +use tokio::net::TcpListener; +use tokio::prelude::*; +use serenity::async_trait; +use serenity::client::{Client, Context, EventHandler}; +use serenity::model::channel::Message; +use serenity::framework::standard::{ + StandardFramework, + CommandResult, + macros::{ + command, + group + } +}; + +mod config; + +use std::env; + +#[group] +#[commands(ping)] +struct General; + +struct Handler; + +#[async_trait] +impl EventHandler for Handler {} + +#[tokio::main] +async fn main() { + let framework = StandardFramework::new() + .configure(|c| c.prefix("!")) // set the bot's prefix to "~" + .group(&GENERAL_GROUP); + + let mut client = Client::new(config::token) + .event_handler(Handler) + .framework(framework) + .await + .expect("Error creating client"); + + // start listening for events by starting a single shard + if let Err(why) = client.start().await { + println!("An error occurred while running the client: {:?}", why); + } +} + +#[command] +async fn ping(ctx: &Context, msg: &Message) -> CommandResult { + msg.reply(ctx, "Pong!").await?; + + Ok(()) +} \ No newline at end of file