make user friendly

This commit is contained in:
squidysquid1
2023-02-12 21:27:32 -06:00
parent abf1f1bb58
commit cc3f8e6048

View File

@@ -20,6 +20,9 @@ use serenity::http::Http;
use serenity::model::channel::Message;
use serenity::model::event::ResumedEvent;
use serenity::model::gateway::Ready;
use serenity::model::Timestamp;
use serenity::model::prelude::Activity;
use serenity::utils::Colour;
use serenity::prelude::*;
use tracing::{error, info};
use std::time::Instant;
@@ -40,7 +43,8 @@ struct Handler;
#[async_trait]
impl EventHandler for Handler {
async fn ready(&self, _: Context, ready: Ready) {
async fn ready(&self, ctx: Context, ready: Ready) {
ctx.set_activity(Activity::listening("!help")).await;
info!("Connected as {}", ready.user.name);
}
@@ -50,7 +54,7 @@ impl EventHandler for Handler {
}
#[group]
#[commands(jackon, jackoff, quit)]
#[commands(jackon, jackoff, jackstats, cumquotes, cumflip, help, quit)]
struct General;
#[tokio::main]
@@ -132,6 +136,7 @@ async fn quit(ctx: &Context, msg: &Message) -> CommandResult {
#[command]
async fn jackon(ctx: &Context, msg: &Message) -> CommandResult {
println!("this buddy sent the message: {}", msg.author.id);
let count = {
let data_read = ctx.data.read().await;
data_read.get::<Time>().expect("Expected Time in TypeMap.").clone()
@@ -179,3 +184,65 @@ async fn jackoff(ctx: &Context, msg: &Message) -> CommandResult {
Ok(())
}
#[command]
async fn cumquotes(ctx: &Context, msg: &Message) -> CommandResult {
let num = rand::thread_rng().gen_range(1..10);
let str = match num{
1=>"Please dm quotes to squid",
_=>"Please dm quotes to squid",
};
msg.channel_id.say(&ctx.http, str).await?;
Ok(())
}
#[command]
async fn jackstats(ctx: &Context, msg: &Message) -> CommandResult {
msg.channel_id.say(&ctx.http, "cmd not implemented").await?;
Ok(())
}
#[command]
async fn cumflip(ctx: &Context, msg: &Message) -> CommandResult {
let toss: bool = rand::thread_rng().gen_bool(0.5);
let str;
if toss {
str = "You landed heads!!! GO AT HER BUD";
}
else{
str = "You landed tails... Back to osrs";
}
msg.channel_id.say(&ctx.http, str).await?;
Ok(())
}
#[command]
async fn help(ctx: &Context, msg: &Message) -> CommandResult {
let msg = msg
.channel_id
.send_message(&ctx.http, |m| {
m.content("")
.embed(|e| {
e.title("Commands")
.fields(vec![
("!help", "Helpful cmd", true),
("!jackon", "Starts jack timer", true),
("!jackoff", "Stops jack timer", true),
("!jackstats", "not implemented", true),
("!cumflip", "Flips coin to do the deed or not", true),
("!cumquotes", "Quotes to get you motivated", true),
])
.timestamp(Timestamp::now())
.color(Colour::DARK_TEAL)
})
})
.await;
if let Err(why) = msg {
println!("Error sending message: {:?}", why);
}
Ok(())
}