-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 208a8f4
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "among-us-discord-bot" | ||
version = "0.1.0" | ||
authors = ["Blake Wyatt <blakewy@live.com>"] | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} |